假如你现在还在为自己的技术担忧,假如你现在想提升自己的工资,假如你想在职场上获得更多的话语权,假如你想顺利的度过35岁这个魔咒,假如你想体验BAT的工作环境,那么现在请我们一起开启提升技术之旅吧,详情请点击http://106.12.206.16:8080/qingruihappy/index.html
项目中有一个功能 在IE中GET方式提交会产生乱码 但有两个入口都会走这同一段代码
固不能直接转码,所以要进行判断传过来的该值是不是乱码
可用以下方式验证:
1 java.nio.charset.Charset.forName("GBK").newEncoder().canEncode("测试") //判断是不是GBK编码 即是否乱码
1 //使用request.getQueryString()获取通过URL传过来的值 有可能是乱码 如:q=éæ¥ 2 String s = request.getQueryString(); 3 if(s!=null){ 4 if(!(java.nio.charset.Charset.forName("GBK").newEncoder().canEncode(s))){ 5 try { 6 s = new String(request.getQueryString().getBytes("ISO-8859-1"),"UTF-8"); 7 } catch (UnsupportedEncodingException e) { 8 e.printStackTrace(); 9 } 10 } 11 }