jQuery地址传参数中文后台乱码

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_24521431/article/details/83061281
function zanchun(){
	var f = document.getElementsByTagName("form")[0];
	f.action=f.action+"process=1"+"&person="+person;
	alert(person);
	alert(f.action);
}
alert(person)显示正常
String REPORTERS=request.getParameter("person");

debug后台看了一下,REPORTERS乱码

问题分析:前台和后台的编码格式不一样

或者TOMCAT的编码格式跟后台,前台不一样

看了一下,我的jsp是utf-8,

项目也是utf-8

改了一下tomcat的编码格式。

成功解决。

修改tomcat编码格式方法:

找到tomcat下的conf/server.xml文件

在这里添加一个属性:URIEncoding,将该属性值设置为UTF-8,即可让Tomcat(默认ISO-8859-1编码)以UTF-8的编码处理get请求。

<Connector port="8080"  protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />

猜你喜欢

转载自blog.csdn.net/qq_24521431/article/details/83061281
今日推荐