1.编码问题
(1)get请求
1)为什么会产生乱码?
对于中文参数值,ie浏览器会使用
“gbk”来编码,其它浏览器会使用”
utf-8”来编码。服务器端默认会使用
“iso-8859-1”来解码。
2)如何解决?
step1,服务器端统一使用”utf-8”来
解码。
修改tomcat的server.xml文件
注:只针对get请求有效。
step2,使用encodeURI函数对请求参数
进行编码。
注:encodeURI是一个内置的函数
,会使用utf-8来编码。
(2)post请求
1)为什么会产生乱码?
浏览器会使用"utf-8"来编码。而服务器
默认使用"iso-8859-1"来解码。
2)如何解决?
request.setCharacterEncoding("utf-8");