今天项目请求json时报了这个诡异的且从来没有遇到到的错误:The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
解决办法:
1、将springmvc 文件的 xsd修改为3.2版本,如:
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
2、将<mvc:annotation-driven/> 修改为
<mvc:annotation-driven content-negotiation-manager="contentNegotiationManager"/>
<bean id="contentNegotiationManager"
class="org.springframework.web.accept.ContentNegotiationManagerFactoryBean">
<property name="favorPathExtension" value="false" />
<property name="favorParameter" value="true" />
<property name="parameterName" value="mediaType" />
<property name="ignoreAcceptHeader" value="true"/>
<property name="useJaf" value="false"/>
<property name="defaultContentType" value="application/json" />
<property name="mediaTypes">
<map>
<entry key="json" value="application/json" />
<entry key="xml" value="application/xml" />
</map>
</property>
</bean>
这样问题得到解决了。。
来源:oschina
链接:https://my.oschina.net/u/2003336/blog/699809