关于get请求的乱码问题

1.使用getBytes()

页面跳转时,参数中含有中文,特殊符号,tomcat的默认编码为ios-8859-1,后台接受中文编码时,使用如下转码

//获取参数

String bname = request.getParameter("bname"); 

//转码

bname = new String(bname .getBytes("iso8859-1"),"utf-8");

2.使用encodeuri(),encodeuricomponent(),后台使用URLDecoder.decode(url, "UTF-8")解码,浏览器在跳转时会先自动decode一层(ie8不会!

posted @ 2017-10-30 19:56  不知所code  阅读(155)  评论(0编辑  收藏  举报