首页 > 代码库 > Servlet乱码

Servlet乱码

Post方式乱码:request.setCharacterEncoding(“utf-8”);

 

GET方式:

1.修改tomcat解码字符集 conf/server.xml   URIEndoing=”utf-8”

2.手动重新编码

username = URLEncoder.encode(username, “ISO-8859-1”);

username = URLDecoder.decode(username,”utf-8”);

简化:

username = new String(username.getBytes(“ISO-8859-1”), “utf-8”);