springboot 拦截器不起作用的原因
程序员文章站
2022-07-12 14:10:59
...
网上有很多其他原因,这里只放我自己犯下的一个愚蠢错误。。记录一下,希望大家也可以参考。在这里插入代码片
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginHandlerInterceptor).addPathPatterns("/**")
.excludePathPatterns("/","/login","/user/login","/index.html");
}
注意:排除哪些不拦截的里面有"/",有很多同学写成"/*",那就不会拦截http://localhost:8080/abc这个url,这是你配置没写对的原因,这是我做实验的时候发现的,拦截器里肯定不能配置"/",要不然登陆界面都进不去啦,不是这个拦截器不起作用。哈哈哈
在这里插入图片描述
推荐阅读