jsp在文本框里输入中文提交到servlet,显示的是乱码

post提交用这个代码处理编码request.setCharacterEncoding("utf-8");

get提交处理编码有2中方法

1:String uname=new String(request.getParameter("uname").getBytes("iso-8859-1"),"UTF-8")

注解:iso-8859-1是get默认编码格式,要用new string 转换为UTF-8

2:该tomcat文件下---conf文件下---server.xml用记事本打开----用查找(ctrl+f)8443,在 这后面加上URIEncoding="UTF-8".

改了文件,以后get就不用处理乱码了!

猜你喜欢

转载自blog.csdn.net/qq_33541802/article/details/81176917
今日推荐