今天在调试springMVC的时候,在将一个对象返回为json串的时候,浏览器中出现异常:
The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers ().
这个错误是因为applicationContext缺少配置json转化bean:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter" />
</list>
</property>
</bean>
<bean id="mappingJacksonHttpMessageConverter" class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
本文介绍了在SpringMVC框架中遇到的一个常见问题——当尝试返回JSON格式的对象时,浏览器显示无法接受响应的问题。文章详细解释了如何通过配置applicationContext来解决此问题,包括添加必要的bean以支持JSON数据转换。
777

被折叠的 条评论
为什么被折叠?



