//解析请求的Json数据
private String getRequestPostData(HttpServletRequest request) {
String response = "";
try {
int contentLength = request.getContentLength();
if (contentLength < 0) {
return null;
}
byte buffer[] = new byte[contentLength];
for (int i = 0; i < contentLength; ) {
int len = request.getInputStream().read(buffer, i, contentLength - i);
if (len == -1) {
break;
}
i += len;
}
response = new String(buffer, "utf-8");
} catch (IOException e) {
e.printStackTrace();
}
return response;
}
然后去调用此方法即可