在SpringMVC4之后jacksonx.jar 都有更改。如果报NoClassDefFoundError错误,一般都会提示no convert type,那么更改一下jackson相关jar包:
1.jackson-annotations-2.5.0.jar
2.jackson-core-2.5.0.jar
3.jackson-databind-2.5.0.jar
springmvc配置也有变动:
<!-- 用于将对象转换为 JSON -->
<bean id="stringConverter"
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
<bean id="jsonConverter"
class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean>
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<ref bean="stringConverter" />
<ref bean="jsonConverter" />
</list>
</property>
</bean
并附上这三个JAR包:
本文出自 “分享是最好的记忆” 博客,请务必保留此出处http://elyar.blog.51cto.com/9864306/1901764
原文地址:http://elyar.blog.51cto.com/9864306/1901764