jsp/servlet乱码解决
1 解决方法 <% @ page contentType = " text/html;charset=utf-8 " %>
2 response.setCharacterEncoding("utf-8");//响应编码类型response.setContentType("text/html;charset=utf-8");//设置文档类型request.setCharacterEncoding("utf-8");//请求编码类型
3 new String(request.getParameter("name").getBytes("ISO8859_1"),"utf-8");
4 修改tomcat的server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="utf-8"
/>
5过滤器配置web.xml
<filter>
<filter-name>w1</filter-name>Set Character Encoding
<filter-class>com.hw.controller.ErrorFilter</filter-class>SetCharacterEncodingFilter
</filter>
<filter-mapping>
<filter-name>w1</filter-name>Set Character Encoding
<url-pattern>/*</url-pattern>
</filter-mapping>
con.hw.controller.EncodingFilter
/*
con.hw.controller.EncodingFilter
/*