我这个方法是将所有的地方都改成utf-8不单单是能解决前端问题
第一:去博主这改一下eclipse编码配置
https://blog.youkuaiyun.com/lanmuhhh2015/article/details/79366872
第二:然后再 servlet中
doget请求中加上
response.setContentType("text/html;charset=utf-8");
//response.setContentType(MIME)的作用是使客户端浏览器,区分不同种类的数据,并根据不同的MIME调用浏览器内不同的程序嵌入模块来处理相应的数据。
第三:去你tomcat安装目录conf下得server.xml
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" 加上这个 URIEncoding="UTF-8"/>