HTTP Status 406 -
type Status report
message
description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
Apache Tomcat/7.0.47
使用ajax请求的时候,代码明明没有问题,而且数据已经更新,但是就是响应失败!
ajax请求响应406大概就两种情况
1.百分之九十的可能是缺少Jackson的包
2.web.xml中前端控制器的拦截形式为 *.html
xxx
*.html
这种情况下在controller中如果响应的是对象,并且使用@ResponseBody注解,使用此种方式返回json数据给页面。
@RequestMapping("/xxx/xxx")
@ResponseBody
public Result updateXXX(){
业务逻辑
...
return Result;
}
这种情况下就会出现406错误。
解决办法也很简单:
针对第一种情况:添加Jackson的依赖就可以
针对第二种情况:可以修改web.xml,此请求使用其他的拦截形式
xxx
*.html
xxx
*.action