异常:getInputStream() has already been called for this request...
造成异常的代码: 从请求中获取body参数
BufferedReader reader = request.getReader();
while ((str = reader.readLine()) != null) {
requestJson += str;
}
reader.close();
原因: 1.重复调用 2.request.getReader获取不到值
解决办法:在获取body 参数的同时,先判断下请求数据流的长度,就完美解决啦
int len = request.getContentLength();
if (len != -1) {
BufferedReader reader = request.getReader();
while ((str = reader.readLine()) != null) {
requestJson += str;
}
reader.close();
}