springmvc的组件:处理器适配置RequestMappingHandlerAdapter 中返回数据的编码默认为:ISO8859-1,所以需要设置向页面转换响应的数据时,将数据默认的编码改为utf-8;在springmvc.xml中设置如下:
注意:一定要将改设置配置在<mvc:annotation-driven>之前。
<bean class="org.springframework.web.servlet.mvc.method.annotation.
RequestMappingHandlerAdapter">
<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>
<bean class="org.springframework.http.converter.json.
MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
SpringMVC 设置 UTF-8 编码
2027

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



