环境:
win10系统语言环境(管理语言设置):中国 台湾 即 big5
浏览器:ie11
url=http://localhost:7022/mycim2/ajaxflush.do?test=信
后台获取
request.setCharacterEncoding(“big5”);
test= request.getParameter(“test”);
System.out.println(“信”.equals(test));//结果为true
//byte[] big5xin = { -85, 72 };//字符"信"的big5字节码
结论:
ie11浏览器的ajax get请求url默认由操作系统语言环境编码
存在的问题:
如果url包含big5不支持的中文,导致后台永远无法正确获取url中的字符,所以要避免默认编码
解决办法
一、前端:
1.1参数用encodeURIComponent(test)编码或 序列化$.param({test:test})后再追加到url后面
1.2直接改post请求
二、后台:
2.1 设置request.setCharacterEncoding(“UTF-8”)后直接获取参数