java后台得到request payload请求中的json请求参数
private String getRequestPayload(HttpServletRequest req) {
StringBuilder sb = new StringBuilder();
try(BufferedReader reader = req.getReader();) {
char[]buff = new char[1024];
int len;
while((len = reader.read(buff)) != -1) {
sb.append(buff,0, len);
}
}catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
调用该方法得到json字符串,解析json字符串即可获取所需参数。