struts2 中文乱码问题
lbwdi 2009-07-08 11:23:34 1、tomcate6 中 tomcate connector字符的设置了URIEncoding="UTF-8"
2、在项目中struts.properties 添加了
struts.devMode=false
struts.enable.DynamicMethodInvocation=true
struts.i18n.reload=true
struts.ui.theme=simple
struts.locale=UTF-8
struts.i18n.encoding=UTF-8
struts.serve.static.browserCache=false
struts.url.includeParams=none
3、web.xml 里面也添加了
<filter>
<filter-name>struts-cleanup</filter-name>
<filter-class>
org.apache.struts2.dispatcher.ActionContextCleanUp
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
4、在jsp页面中的也设置了字符编码
<%@page pageEncoding="UTF-8"%>
<%@ page contentType="text/vnd.wap.wml; charset=UTF-8"%>
以上设置完为什么还是有中文乱码的问题?
url中输入了一个中文
在action中用以下代码
String name=request.getParameter("name");
name=new String(name.getBytes("ISO-8859-1"),"UTF-8");
System.out.println(name);
打印出的还是 ??