在SpringBoot中写注册自定义配置的拦截器时
//注册拦截器
@Override
public void addInterceptors(InterceptorRegistry registry) {
//拦截任意多层路径下的任意请求
//静态资源:;
//springBoot已经做好了静态资源映射,所有不需要管静态资源
registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
.excludePathPatterns("index.html","/","/user/login");
}
registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
.excludePathPatterns("index.html","/","/user/login");
这里面的index.html少写了一个/,
应该改为 registry.addInterceptor(new LoginHandlerInterceptor()).addPathPatterns("/**")
.excludePathPatterns("/index.html","/","/user/login");