我正在使用 springMVC 3.2.6 和 Hibernate 3.3.1 开发 Web 应用程序
当我将 spring URL 模式映射为 *.htm
时
并请求 URL 为 getname.htm
该方法在 Debug模式和 system.out.println
中检查时工作正常,但未生成 JSON,输出显示为
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().
当我将 spring URL 模式映射为 /rest/
并请求 url 为 /rest/getname
时,它提供了完美的 JSON 输出:
@RequestMapping(value = "/getname", method = RequestMethod.GET,produces = "application/json")
public @ResponseBody
List<String> getNameInJSON() {
}
最佳答案
尝试检查浏览器调试器中的“接受” header 并使用 produces 属性。
关于java - Spring JSON url 模式 Not Acceptable ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20608724/