在springmvc中加:
<beanid="mappingJacksonHttpMessageConverter"
class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter">
<propertyname="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
<!-- 启动SpringMVC的注解功能,完成请求和注解POJO的映射 -->
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<propertyname="messageConverters">
<list>
<refbean="mappingJacksonHttpMessageConverter"/> <!--JSON转换器 -->
</list>
</property>
</bean>
如果已经有启动springmvc的注解功能的bean,那就在里面加property这段:
<property name="messageConverters">
<list>
<ref bean="mappingJacksonHttpMessageConverter"/> <!--JSON转换器 -->
</list>
</property>