一个项目 多个拦截器

1. addInterceptors 方法中加多条

 

 

 

@Configuration
public class ResourcesConfig implements WebMvcConfigurer{

   @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(new AppInterceptor())
                .addPathPatterns("/project/**");
     //这里可以加多条 } }

 

public class AppInterceptor implements HandlerInterceptor{

}

 

 

 

 

 2. 拦截器中调用service 为空解决:

BeanFactory factory = WebApplicationContextUtils
                        .getRequiredWebApplicationContext(request.getServletContext());
menuService = (ISysMenuService) factory
                        .getBean("sysMenuServiceImpl");

 

 

 
posted @ 2023-01-16 14:13  DarGi  阅读(232)  评论(0编辑  收藏  举报