怎样去理解@ComponentScan注解
1个回答
展开全部
@Override
public void addInterceptors(InterceptorRegistry registry) {
// 多个拦截器组成一个拦截器链
// addPathPatterns 用于添加拦截规则
// excludePathPatterns 用户排除拦截
registry.addInterceptor(new MyInterceptor()).addPathPatterns(;/**;);
}
}
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@WebFilter(filterName=;myFilter;,urlPatterns=;/*;)
public class MyFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println(;**********************************过滤器初始化***********************************/n;);
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
System.out.println(;***********************************执行过
public void addInterceptors(InterceptorRegistry registry) {
// 多个拦截器组成一个拦截器链
// addPathPatterns 用于添加拦截规则
// excludePathPatterns 用户排除拦截
registry.addInterceptor(new MyInterceptor()).addPathPatterns(;/**;);
}
}
?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
@WebFilter(filterName=;myFilter;,urlPatterns=;/*;)
public class MyFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {
System.out.println(;**********************************过滤器初始化***********************************/n;);
}
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
System.out.println(;***********************************执行过
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询