日期:2014-05-16 浏览次数:20335 次
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().
?
经过排查原来是配置文件方式不同引起的:
首先引入
jackson-core-asl-1.6.4.jar
jackson-mapper-asl-1.6.4.jar
如果是:
<mvc:annotation-driven />
那么则没有问题
?
如果把配置换成
?
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping" />
?
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
则会报异常。
那么需要补充配置
?
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
? ?<property name="messageConverters">
? ?<list>
? ? <ref bean="jsonHttpMessageConverter"/>
? ?</list>
? ?</property>
</bean>
<bean id="jsonHttpMessageConverter"?
? ? ? ?class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter"/>
?
-- 其他的list的没写,只是为了测试
?
?
http://stackoverflow.com/questions/3340050/springs-json-not-being-resolved-with-appropriate-response
?
http://stackoverflow.com/questions/2828968/mapping-restful-ajax-requests-to-spring