如何解决get和post乱码问题?

解决 post 请求乱码:我们可以在 web.xml 里边配置一个 CharacterEncodingFilter 过滤器。 设置为 utf-8. 
解决 get 请求的乱码:有两种方法。对于 get 请求中文参数出现乱码解决方法有两个:

1. 修改 tomcat 配置文件添加编码与工程编码一致。  

2. 另 外 一 种 方 法 对 参 数 进 行 重 新 编 码 String userName = New   String(Request.getParameter(“userName”).getBytes(“ISO8859-1”), “utf-8”);

猜你喜欢

转载自www.cnblogs.com/xwqllp/p/10761060.html