欢迎访问悦橙教程(wld5.com),关注java教程。悦橙教程  java问答|  每日更新
页面导航 : > > 文章正文

spring mvc3 @ResponseBody 中文乱码解决方案,mvc3@responsebody,通过配置解决spring

来源: javaer 分享于  点击 25919 次 点评:159

spring mvc3 @ResponseBody 中文乱码解决方案,mvc3@responsebody,通过配置解决spring


通过配置解决spring3 mvc @ResponseBody 乱码问题。网上好多兄弟姐妹都是转发的帖子,时灵时不灵的,小弟我跟踪断点后,使用如下方式注入,可以解决问题。为了与spring默认注入的一直,所以加了好几个convert

[Java]代码

 <bean   class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">   <property name="messageConverters">    <list>     <bean      class="org.springframework.http.converter.ByteArrayHttpMessageConverter" />     <bean      class="org.springframework.http.converter.StringHttpMessageConverter">      <property name="supportedMediaTypes">       <list>        <value>text/plain;charset=UTF-8</value>       </list>      </property>     </bean>     <bean      class="org.springframework.http.converter.ResourceHttpMessageConverter" />     <bean      class="org.springframework.http.converter.xml.SourceHttpMessageConverter" />     <bean      class="org.springframework.http.converter.xml.XmlAwareFormHttpMessageConverter" />     <bean      class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter" />    </list>   </property>  </bean>  <mvc:annotation-driven />
相关栏目:

用户点评