1,从页面上处理:
<%@ page contentType="text/html; charset=UTF-8"%>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
2.从tomcat 修改server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="utf-8"/>
3.在项目web.xml
<filter>
<filter-name>encodingFilter</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>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
如果现在传递中文还是乱码,你还要注意,你是否用post传递
如果都不行,证明有未知错误,找不到的话,只能使用笨方法,既然我不知道我传递的过程,参数是被转成了什么码,那我干脆在传递的时候就给他编码,编我知道的,然后我在接收的时候,对它解码,这就是笨方法,一般情况可以使用.....建议还是找到出错的地方,这方法,治标不治本
ServletActionContext.getResponse().setCharacterEncoding("UTF-8");
ServletActionContext.getResponse().getWriter().write(URLEncoder.encode(sb.toString(),"UTF-8"));
alert(decodeURI(msg));