接触springMVC不够深入,乱码困扰我到深夜,特此留下记忆:
@responsebody默认滴是那个什么8859-1滴狗屁编码,需要在配置文件中加入如下代码转换:
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
<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>
本文介绍了解决SpringMVC项目中乱码问题的方法,通过配置文件设置正确的字符编码UTF-8,确保@responsebody返回的数据能正确显示。
1298

被折叠的 条评论
为什么被折叠?



