ajax数据传递过程中中文乱码问题

1.GET请求:将Tomcat服务器中的server.xml文件修改如下所示:

<Connector 

port="80" 

protocol="HTTP/1.1" 

connectionTimeout="20000" 

redirectPort="8443" 

URIEncoding=”UTF-8”/>

2.POST请求:在js中使用ajax对象发送请求的时候设置如下的请求头信息:

xmlHttpRequest.setRequestHeader("Content-Type",

"application/x-www-form-urlencoded;charset=UTF-8");

l 以上两种方式,在编写Servlet的时候,都不需要在Servlet中编写如下代码:

request.setCharacterEncoding(“UTF-8”);

原文地址:https://www.cnblogs.com/anxue/p/4705399.html