主要需要注意一下两点:
1、web.xml中需要设置过滤器,如下:
<filter>
<filter-name>SpringEncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
2、?useUnicode=true&characterEncoding=UTF-8 用于.properties文件
?useUnicode=true&characterEncoding=UTF-8 用于.xml文件
时间: 2024-10-09 16:34:39