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

How to solve the failure of springboot Interceptor interceptor excludePathPatterns ignore

王林
王林forward
2023-05-26 12:20:582663browse

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");

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!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete