registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/index.html") index.html还是会被拦截
时间: 2024-05-04 18:22:09 浏览: 20
可以尝试将 `excludePathPatterns` 中的 `/index.html` 改为 `/index.html/**`,这样就可以排除掉 `/index.html` 及其子路径下的所有请求。即:
```
registry.addInterceptor(new LoginInterceptor())
.addPathPatterns("/**")
.excludePathPatterns("/index.html/**");
```
这样配置之后,对于 `/index.html` 页面及其子路径下的请求,将不会被 `LoginInterceptor` 拦截。
相关问题
registry.addInterceptor(myInterceptor) .addPathPatterns("/**") .excludePathPatterns("/login.html")
这是一个使用 Spring MVC 框架的拦截器配置代码。该代码将 myInterceptor 拦截器添加到所有请求路径("/**")中,并排除了 "/login.html" 路径,即在访问 "/login.html" 时不会被该拦截器拦截。拦截器可以在请求处理前、请求处理后以及视图渲染后执行一些操作,比如权限校验、日志记录等。
registry.addInterceptor(jwtInterceptor).addPathPatterns("/api/**").excludePathPatterns("/api/admin/login");
This code adds a JWT interceptor to the registry to intercept all requests with a path starting with "/api/", except for requests to the "/api/admin/login" endpoint.
The purpose of the interceptor is to check if the request contains a valid JWT token in the Authorization header, and if not, reject the request with a 401 Unauthorized response. This helps to secure the API by requiring clients to authenticate before accessing protected resources.