Spring 3.x JSON status 406 “characteristics not acceptable according to the request ”accept“ headers ()”

后端 未结 14 1466
太阳男子
太阳男子 2020-12-13 01:50

Upon trying to get my response in JSON using Spring 3.x, I get the 406 error \"The resource identified by this request is only capable

14条回答
  •  清歌不尽
    2020-12-13 02:27

    Please, see http://docs.spring.io/spring-framework/docs/3.2.x/spring-framework-reference/html/mvc.html#mvc-config-content-negotiation As you can see

    "For file extensions in the request URI, the MVC Java config and the MVC namespace, automatically register extensions such as .json, .xml, .rss, and .atom if the corresponding dependencies such as Jackson, JAXB2, or Rome are present on the classpath."

    You should add ".json" at the end of URI (like http://domain/SpringWebProject/json/contest/abcd.json) It works for me.

提交回复
热议问题