解决 post 请求乱码:我们可以在 web.xml 里面配置一个 CharacterEncodingFilter 过滤器。设置为 UTF-8 解决 get 请求的乱码:有两种方法。对于 get 请求中文参数出现乱码解决方法有两个:
1、修改 tomcat 配置文件添加码与工程编码一致。
2、另一种方法对参数进行重新编码 String userName = New String(Request.getParameter("userName").getBytes("ISO8859-1"),"utf-8");