原因:后台使用的是springMVC,方法使用@ResponseBody,方法返回JSONObject
解决方法:方法改为void,返回数据改为
PrintWriter pw = null;
try {
pw = response.getWriter();
pw.print(jsonObject);
pw.close();
} catch (IOException e) {
e.printStackTrace();
}
本文介绍了解决Spring MVC中使用@ResponseBody注解返回JSONObject时的问题。通过将方法返回类型更改为void,并利用PrintWriter直接向响应中写入JSON对象,可以有效解决此问题。
原因:后台使用的是springMVC,方法使用@ResponseBody,方法返回JSONObject
解决方法:方法改为void,返回数据改为
PrintWriter pw = null;
try {
pw = response.getWriter();
pw.print(jsonObject);
pw.close();
} catch (IOException e) {
e.printStackTrace();
}

被折叠的 条评论
为什么被折叠?