Java获取POST请求Json格式参数raw

 

在这里插入图片描述

 

有两种方式:

1、已流的方式接收请求参数

// request为HttpServletRequest对象
BufferedReader br = null;
try {
    br = new BufferedReader(new InputStreamReader(request.getInputStream(), "UTF-8"));
} catch (IOException e) {
    e.printstacktrace();
}
String line = null;
StringBuilder sb = new StringBuilder();
try {
    while ((line = br.readLine()) != null) {
        sb.append(line);
    }
    br.close();
} catch (IOException e) {
    e.printstacktrace();
}

 

2、@RequestBody注解 接收

 

@RequestMapping(value = "/technicalReviewInfo", method = RequestMethod.POST,produces = "application/json;charset=utf-8")
@ResponseBody
public JSONObject synTechnicalReviewInfo(@RequestBody JSONObject technicalReviewJson) {
    JSONObject json=new JSONObject();
    return json;
}

 

      转自:https://blog.csdn.net/weixin_42096792/article/details/121661148

相关文章

AJAX是一种基于JavaScript和XML的技术,能够使网页实现异步交...
在网页开发中,我们常常需要通过Ajax从后端获取数据并在页面...
在前端开发中,经常需要循环JSON对象数组进行数据操作。使用...
AJAX(Asynchronous JavaScript and XML)是一种用于创建 We...
AJAX技术被广泛应用于现代Web开发,它可以在无需重新加载页面...
Ajax是一种通过JavaScript和HTTP请求交互的技术,可以实现无...