1. 确认工程编码是UTF-8
右击工程名,单击properties,单击Resource,把Text file encoding设置为UTF-8
2. 确认工作空间为UTF-8
单击windows->General->Workspace,把Text file encoding设置为UTF-8
3. 将jsp请求设置为UTF-8
在页头添加<%@page contentType="text/html; charset=UTF-8" %>
4. 将jsp响应设置为UTF-8
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
5. 如果还有乱码则在struts.xml中设置中文字符集:
<constant name="struts.i18n.encoding" value="utf-8"></constant>
6. 如果还有乱码,在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>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>CharacterEncoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
7. 如果还有乱码,在Action中的response字符集设置为UTF-8:
ServletActionContext.getResponse.setCharacterEncoding("utf-8");
8. 如果还有乱码,则将服务器跳转配置设置为UTF-8:
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余1页未读,立即下载