- 内容为原创转载请附地址
原因是:org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error
也是一个controller路径为/error
@Configuration
public class MVCConfig extends WebMvcConfigurationSupport {
//自定义的拦截器
@Bean
public SecurityInterceptor getSecurityInterceptor() {
return new SecurityInterceptor();
}
@Override
public void addInterceptors(InterceptorRegistry registry) {
//添加拦截器
InterceptorRegistration registration = registry.addInterceptor(getSecurityInterceptor());
//排除的路径
registration.excludePathPatterns("/login");
registration.excludePathPatterns("/logout");
//将这个controller放行
registration.excludePathPatterns("/error");
//拦截全部
registration.addPathPatterns("/**");
}
}