【发布时间】:2015-10-12 07:08:53
【问题描述】:
下面是我写的代码。
@RequestMapping(value = "/getData", method = RequestMethod.GET)
public @ResponseBody Map<String,String> test() throws IOException {
Map<String,String> map = new HashMap<String,String>();
map.put("key","value");
map.put(null, "Key's Value"); //**This highlighted code causing the problem, if I remove this then it works fine.**
return map;
}
当我点击 URL localhost:8080/myapp/getData
我收到以下回复
10.5.1 500 内部服务器错误 服务器遇到了一个意外情况,导致它无法完成请求。
即使 Spring 也不会打印任何服务器端异常!
我想知道 Spring 无法处理 key 为 null 的 JSON 响应的根本原因。
【问题讨论】:
标签: java json spring spring-mvc