一般出现406错误有两种可能:
1、如果后缀是html是不能响应json数据的。需要修改后缀名。
在做伪静态化过程中,以.html结尾的后缀,做post请求时,不能响应json格式,这是spring官方做出的处理
可以加一个后缀改为.action 2、查看Jackson包是否存在。
spring MVC默认依赖Jackson包
第一种问题的解决方案:
第二种问题的解决方案:
在springMVC配置文件中添加以下代码:
atom = application/atom+xml
html = text/html
json = application/json
* = */*
text/html;charset=UTF-8
在pom.xml 添加如下依赖:
com.fasterxml.jackson.core
jackson-core
2.8.1
com.fasterxml.jackson.core
jackson-databind
2.8.1
com.fasterxml.jackson.core
jackson-annotations
2.8.1