用的Tomcat6 %Tomcat6.0%\webapps\examples\WEB-INF\classes\filters目录下有个SetCharacterEncodingFilter.java
直接拿来用了 两个System.out.println是我自己加的 public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
System.out.println("request本身是否有编码:" + request.getCharacterEncoding()); // Conditionally select and set the character encoding to be used
if (ignore || (request.getCharacterEncoding() == null)) {
String encoding = selectEncoding(request);
System.out.println("设置编码:" + encoding);
if (encoding != null)
request.setCharacterEncoding(encoding);
} // Pass control on to the next filter
chain.doFilter(request, response); }为什么我请求什么页面控制台都显示:request本身是否有编码:null
设置编码:UTF-8我所有页面都有设置字符集UTF-8,post提交,怎么到了过滤器变null了呢