标签:over void boot chain import rri etc can int
MyFilter1.java
package com.zns.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.annotation.WebFilter; @WebFilter(filterName = "myFilter1", urlPatterns = "/*") public class MyFilter1 implements Filter { @Override public void init(FilterConfig config) throws ServletException { System.out.println("过滤器初始化"); } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { System.out.println("执行过滤操作"); chain.doFilter(request, response); } @Override public void destroy() { System.out.println("过滤器销毁"); } }
在启动类增加@ServletComponentScan注解
标签:over void boot chain import rri etc can int
原文地址:https://www.cnblogs.com/zengnansheng/p/10389789.html