想要加载拦截器,就需要继承WebMvcConfigurerAdapter
public class SpringMvcConfig extends WebMvcConfigurerAdapter {
@Autowired
private MyInterceptor1 myInterceptor1;
@Override
public void addInterceptors(InterceptorRegistry registry) {
InterceptorRegistration interceptorRegistration1 = registry.addInterceptor(myInterceptor1);
interceptorRegistration1.addPathPatterns("/**");
}
}