一个项目 多个拦截器
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");
-------博客内容仅用于个人学习总结-------