1、通过字符流或字节流获取

@ApiOperation("desc")
@RequestMapping(value = "/api", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json;charset=UTF-8")
public RespData<Boolean> api(
HttpServletRequest request,
HttpServletResponse response) {
BufferedReader br = request.getReader(); String str, body = ""; while((str = br.readLine()) != null){ body += str; } log.info(body); }

@ApiOperation("desc")
@RequestMapping(value = "/api", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json;charset=UTF-8")
public RespData<Boolean> api(
HttpServletRequest request,
HttpServletResponse response) {
int length = request.getContentLength(); ServletInputStream input = request.getInputStream(); byte[] buffer = new byte[length]; input.read(buffer, 0, length);
log.info(new String(buffer));

}

2、通过字@RequestBody获取
@ApiOperation("desc")
@RequestMapping(value = "/api", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json;charset=UTF-8")
public RespData<Boolean> api(@ApiParam(value = "id", required = false) @RequestParam(value = "id",required = false) Long id,@RequestBody String body,
HttpServletRequest request,
HttpServletResponse response) {
log.info("body---->{}",body);

}
 
 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-04-06
  • 2021-10-15
  • 2021-08-15
猜你喜欢
  • 2021-05-30
  • 2022-03-05
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-08-24
  • 2022-12-23
相关资源
相似解决方案