请求乱码问题的解决方案

请求乱码问题的解决方案:

1.使用String进行数据重新编码

示例1:

//万能,但麻烦
uname = new String (uname.getBytes("iso8859-1"),"utf-8");	//使用String进行重新编码
2.使用公共配置

post方式
示例2:

req.setCharacterEncoding("utf-8");	//post好使,get不好使
//因为:get的用户请求数据在url中

get方式
示例3:
步骤一:

req.setCharacterEncoding("utf-8");	

步骤二:修改server.xml文件
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/Xxacker/article/details/85014943
今日推荐