(1)加上produces = {"application/json;charset=UTF-8"}
@RequestMapping(value="/birthday.chtm",produces = {"application/json;charset=UTF-8"})
(2)在spring-mvc.xml中配置
注意 4+版本的spring-mvc要使用 http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd
<mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <constructor-arg value="#{T(java.nio.charset.Charset).forName('UTF-8')}"/> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>text/html;charset=UTF-8</value> <value>applicaiton/javascript;charset=UTF-8</value> </list> </property> <property name="writeAcceptCharset"><value>false</value></property> </bean> <bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>application/json; charset=UTF-8</value> <value>application/x-www-form-urlencoded; charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven>