过时应用:
@Configuration public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/user/login"); super.addInterceptors(registry); } }
新的替代:
@Configuration public class WebMvcConfg implements WebMvcConfigurer { //一系列实现方法 } @Configuration public class WebMvcConfg extends WebMvcConfigurationSupport { @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/user/login"); super.addInterceptors(registry); } }
推荐使用后面那种方式