使用HttpServletRequest获取请求body
时间: 2023-11-25 17:46:57 浏览: 104
(HttpServletRequest获得请求参数
5星 · 资源好评率100%
可以使用HttpServletRequest的getReader()方法获取请求body,示例代码如下:
```
HttpServletRequest request = ...;
StringBuilder sb = new StringBuilder();
BufferedReader reader = request.getReader();
char[] buf = new char[1024];
int len;
while ((len = reader.read(buf)) != -1) {
sb.append(buf, 0, len);
}
String requestBody = sb.toString();
```
阅读全文