1 使用String进行数据重新编码
uname=new String(uname.getBytes("iso8859-1"),"utf-8");
2使用公共配置
get方式:
步骤一:
req.setCharacterEncoding("utf-8");
步骤二:
在tomcat的目录下conf目录中修改server.xml文件:在Connector标签中增加属性 useBodyEncodingForURI="true"
post方式:
req.setCharacterEncoding("utf-8");