方法一:过滤全部请求,但仍是有问题,最后发现是表单的问题,在表单中method默认是get,而以上过滤器只对post有效果,若是是get,须要修改 Tomcat根式目录的 conf/server.xml文件中,找<Connector port="8080" />,在里面加URIEncoding="utf-8"java
方法二 : controller代码里加入contentValue = new String(new String(contentValue.getBytes("ISO-8859-1"), "UTF-8"); contentValue为参数post
<%@ page import="java.net.URLEncoder" %> encodeURI(encodeURI(q),"utf-8")