//@WebFilter("/*") *表示拦截所有请求 @WebFilter("/servletDemo1") public class FilterDemo implements Filter { @Override public void init(FilterConfig filterConfig) throws ServletException { System.out.println("对象初始化。。。"); } @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { System.out.println("filter执行了。。。"); servletResponse.setContentType("text/html;charset=utf-8"); filterChain.doFilter(servletRequest, servletResponse); } @Override public void destroy() { System.out.println("对象销毁。。。"); } }
标签:基本,void,System,servletResponse,使用,Override,public,out From: https://www.cnblogs.com/weiduaini/p/17255593.html