在测试过程中,最开始使用字节流获取body内容,获取失败,亲测字符流可以获取到body内容;
以下为代码内容:
/**
* 通过字符串读取的方式获取请求的body内容
* @param request
* @return
* @throws Exception
*/
private JSONObject readGetBody(HttpServletRequest request) throws Exception{
BufferedReader br = request.getReader();
String foo, wholeStr = "";
while((foo = br.readLine()) != null){
wholeStr += foo;
}
JSONObject jsonObject = JSONObject.parseObject(wholeStr);
return jsonObject;
}

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-01-12
  • 2022-02-07
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2021-10-07
相关资源
相似解决方案