首页 > 其他分享 >一个项目 多个拦截器

一个项目 多个拦截器

时间:2023-01-16 14:22:18浏览次数:43  
标签:AppInterceptor 拦截器 多个 项目 factory class registry public

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");

 

 

 

标签:AppInterceptor,拦截器,多个,项目,factory,class,registry,public
From: https://www.cnblogs.com/DarGi2019/p/17055292.html

相关文章