servlet doGet()方法获取字符串乱码问题
当你遇到ajax向servlet发送数据出现乱码问题的时候不要惊慌,现有以下两个解决办法
(1)在doGet和doPost方法中添加以下代码
request.setCharactersEncoding("UTF-8");
response.setCharacterEncoding("UTF-8");
(2)修改tomcat->conf->server.xml文件中
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8"/>
注意是这一句 URIEncoding="UTF-8",谢谢!