Spring MVC 3.2 406 Not Acceptable
Spring MVC 3.2 406 Not Acceptable 这个报错主要是因为SpringMVC配置文件配置问题。
修改步骤如下:
首先,修改spring-mvc.xsd为 spring-mvc-3.2.xsd
其次,添加如下配置:
1 <!--避免ajax请求出现406错误--> 2 <mvc:annotation-driven content-negotiation-manager="contentNegotiationManager" /> 3 <bean id="contentNegotiationManager" class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean"> 4 <!-- restful 是否采用扩展名的方式确定内容格式,id.json 返回JSON格式 --> 5 <property name="favorPathExtension" value="false" /> 6 <!-- restful 是否采用参数支持确定内容格式,id?format=json 返回JSON格式 --> 7 <property name="favorParameter" value="false" /> 8 <!-- restful 是否忽略掉accept header,Accept:application/json --> 9 <property name="ignoreAcceptHeader" value="false" /> 10 <property name="mediaTypes" > 11 <value> 12 atom=application/atom+xml 13 html=text/html 14 json=application/json 15 *=*/* 16 </value> 17 </property> 18 </bean>
每天进步一点点