本帖最后由 object______du_ 于 2019-3-20 13:50 编辑
过滤器
package cn.itcast.web.filter;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
//过滤器
// @WebFilter("/*")
public class FilterDemo1 implements Filter {
@Override //初始化
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override //过滤器
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
System.out.println("过滤器执行了.......");
//设置放行
filterChain.doFilter(servletRequest,servletResponse);
System.out.println("过滤器返回执行了.......");
}
@Override//销毁
public void destroy() {
}
}
|
|