链接:
http://blog.csdn.net/clarkcc1988/article/details/6893760
http://blog.csdn.net/sunlovefly2012/article/details/25237859
http://blog.csdn.net/qianling3439/article/details/4029772
http://blog.csdn.net/taotaotaotao910429/article/details/8626421
http://blog.csdn.net/joyous/article/details/1504274
在传递参数的时候,如果有中文,那么可以先转码再传,拿到数据后再解码使用。
a.在传参数之前先把参数进行转码:java.net.URLEncoder.encode(param);
取值时用语句java.net.URLDecoder.decode(param);再转回中文
//java: String strTest = "?=abc?中%1&2<3,4>"; strTest = URLEncoder.encode(strTest, "UTF-8"); System.out.println(strTest); strTest = URLDecoder.decode(strTest,"UTF-8"); System.out.println(strTest); //执行结果: //%3F%3Dabc%3F%E4%B8%AD%251%262%3C3%2C4%3E //?=abc?中%1&2<3,4>
b.前端js中还可使用类似:encodeURI( "你好","utf-8");
c.
前端调用URLEncoder.encode(name,"utf-8");要调用两次,
后端解码URLDecoder.decode(urlname,"utf-8"); 调用1次