spring mvc中的拦截器,怎样获取reqeust中的json数据
1个回答
展开全部
public String getStrResponse(HttpServletRequest request) {
InputStream inputStream;
String strResponse = "";
try {
inputStream = request.getInputStream();
String strMessage = "";
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
while ((strMessage = reader.readLine()) != null) {
strResponse += strMessage;
}
reader.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return strResponse;
}
InputStream inputStream;
String strResponse = "";
try {
inputStream = request.getInputStream();
String strMessage = "";
BufferedReader reader;
reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
while ((strMessage = reader.readLine()) != null) {
strResponse += strMessage;
}
reader.close();
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
return strResponse;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询