1.web.xml文件中配置过滤器,加入如下代码:
<filter>
<filter-name>CharacterEncoding</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>
</filter>
<filter-mapping>
<filter-name>CharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
2.jsp页面需要将编码格式写成utf-8的形式
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
3.在tomcat中添加 URIEncoding=”UTF-8”:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" URIEncoding="UTF-8"/>
这个文件在Servers目录下的server.xml文档中。