Home > Java > javaTutorial > How to solve the failure of springboot Interceptor interceptor excludePathPatterns ignore

How to solve the failure of springboot Interceptor interceptor excludePathPatterns ignore

王林
Release: 2023-05-26 12:20:58
forward
2709 people have browsed it

springboot Interceptor interceptor excludePathPatterns ignores the failure

excludePathPatterns method is to exclude the access path, but when the url path you exclude does not exist in the project, springboot will program the path/error, making it impossible to proceed Exclude.

For example, the following code:

registry.addInterceptor(new MyInterceptor()).addPathPatterns("/**").excludePathPatterns("/login");
Copy after login

If the /login access path does not exist in the project, then when you access http://xxxx/login time, it will still be intercepted, because it becomes the error path at this time, which can also be verified through request.getRequestUrl in your custom interceptor.

But if you are using an ordinary springmvc project , it will not be intercepted at this time, but because there is no login path, the 404 page will be displayed.

springboot interceptor exclusion is invalid, excludePathPatterns in springboot is invalid

You can visit it with a breakpoint to see Whether the accessed path is the same as the configured path or invalid

springboot Interceptor拦截器excludePathPatterns忽略失效怎么解决

The above is the detailed content of How to solve the failure of springboot Interceptor interceptor excludePathPatterns ignore. For more information, please follow other related articles on the PHP Chinese website!

source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template