在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配置也有变动:

  1. <!-- 用于将对象转换为 JSON  -->  

  2.     <bean id="stringConverter"  

  3.         class="org.springframework.http.converter.StringHttpMessageConverter">  

  4.         <property name="supportedMediaTypes">  

  5.             <list>  

  6.                 <value>text/plain;charset=UTF-8</value>  

  7.             </list>  

  8.         </property>  

  9.     </bean>  

  10.     <bean id="jsonConverter"  

  11.         class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"></bean>  

  12.     <bean  

  13.         class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  

  14.         <property name="messageConverters">  

  15.             <list>  

  16.                 <ref bean="stringConverter" />  

  17.                 <ref bean="jsonConverter" />  

  18.             </list>  

  19.         </property>  

  20.     </bean

并附上这三个JAR包: