1. 前端设置编码方式:如 jsp
pageEncoding="UTF-8"%>
2. 程序Server端设置编码方式,可以通过配置Filter的方式实现,在web.xml中配置如下:
<filter>
<filter-name>Set Character Encoding</filter-name>
<filter-class>com.chingcloud.demo.util.SetCharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>ignore</param-name>
<param-value>true</param-value>
</init-param>
</filter>
?
<filter-mapping>
<filter-name>Set Character Encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
?
4. 数据库Server端,每个Table设置编码方式
DEFAULT CHARSET=utf8