springmvc 返回汉字乱码

1、删除配置文件中的<mvc:annotation-driven  />

2、添加如下配置

 <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">  
        <property name="cacheSeconds" value="0" />  
        <property name="messageConverters">  
             <list>  
                 <bean class = "org.springframework.http.converter.StringHttpMessageConverter">  
                    <property name = "supportedMediaTypes">  
                          <list>  
                              <value>text/html;charset=UTF-8</value>  
                         </list>  
                    </property>  
                 </bean>  
            </list>  
        </property>  
    </bean>  

 

posted on 2015-11-04 16:06  lvlv岁月流逝  阅读(171)  评论(0编辑  收藏  举报

导航