简体   繁体   English

Spring 引导拦截器 - 如何排除一些 URL

[英]Spring Boot interceptor - how to exclude some URL

I'd like to exclude this endpoint URL from my global interceptor (the whole Controller):我想从我的全局拦截器(整个控制器)中排除这个端点 URL:

@RequestMapping(value = "/api/rest/v1/company/{companyId}/store")
@RestController()
@RequiredArgsConstructor
@Slf4j
public class StoreController {


@GetMapping(with request params)

@PostMapping()

I tried many options like:我尝试了很多选择,例如:

 @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(new GlobalInterceptor(taService, authService))
                .excludePathPatterns("**/store")
                .pathMatcher(new AntPathMatcher());
    }

but without success.但没有成功。

Additionally I want to exclude patterns with query parameters like:此外,我想排除带有查询参数的模式,例如:

/api/rest/v1/company/{companyId}/store?param1=abc&param2=def

And probably I should exclude all Swagger urls也许我应该排除所有 Swagger 网址

I found a solution (there was missing slash "/"):我找到了一个解决方案(缺少斜杠“/”):

 @Override
    public void addInterceptors(InterceptorRegistry registry)
    {
        registry.addInterceptor(new GlobalInterceptor(taService, authService))
                .excludePathPatterns("/**/store")
                .pathMatcher(new AntPathMatcher());
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM