工作中遇到要从HttpServletRequest request中获取body的值,不像mvc一样可以直接@RequestBody获取,

代码:

BufferedReader br = request.getReader();
            String str = "";
            String listString = "";
            while ((str = br.readLine()) != null) {
                listString += str;
            }

system.out.println(listString );

前端url请求格式,我这里body的数据是json格式

从HttpServletRequest中读取请求body中的数据

相关文章:

  • 2021-04-04
  • 2022-12-23
  • 2021-08-09
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
  • 2021-09-26
  • 2021-12-19
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案