ajax无法返回json数据报错406的解决方法

来源:互联网 发布:德国二战军装淘宝 编辑:程序博客网 时间:2024/05/18 15:04

遇到在ajax异步请求的时候,报错406,无法返回一个json数据,一般有两种原因:

1.Spring 4 requires the recent Hibernate Validator 4.3+, and support for Jackson has been focused on 2.0+ now (with Jackson 1.8/1.9 support retained for the time being where Spring 3.2 had it; now just in deprecated form).没有jackson的包,或者是jackson的版本太低,与spring不匹配。

2.后缀为.html的请求是不能够返回json数据的,可以在springmvc的前端控制器配上两个拦截器,一个为.html,另一个为.action。这样的话,在ajax请求的时候就可以把url的后缀改成.action也可以返回json数据了。

原创粉丝点击