一、@RequestMapping注解设置
在Controller对于的接口的@RequestMapping注解中加入produces= MediaType.TEXT_PLAIN_VALUE+";charset=utf-8";
二、修改spring-mvc.xml配置文件
增加以下内容:
<mvc:annotation-driven>
<mvc:message-converters>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
<value>text/plain;charset=UTF-8</value>
<value>application/xml;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>