Spring MVC 4.1.6 Json 406 错误

用浏览器访问的时候报406 错误。

错误信息:

The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.

这是由于spring mvc的版本和jackson的jar版本兼容的问题。

通常spring mvc 3.1.x 与jackson 1.9 可以兼容。

但是当用 spring mvc 4.x 版本的时候却发现,可以用的json功能报错了。

下载最新的jackson版本,测试过2.5的 jackson可以和 spring mvc 4.1.6 兼容。

jackson 下载地址:

https://github.com/FasterXML/jackson-annotations/wiki

https://github.com/FasterXML/jackson-core/wiki

https://github.com/FasterXML/jackson-databind/wiki

需要分别下载这下个jar.导入即可。

Jackson 下载的overview:

http://wiki.fasterxml.com/JacksonDownload

猜你喜欢

转载自codyjava.iteye.com/blog/2215778
今日推荐