excludePathPatterns怎么放行多个路径
可以使用数组的方式来放行多个路径,例如:
@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new LoginInterceptor())
.addPathPatterns("/**")
.excludePathPatterns(new String[]{"/login", "/register", "/logout"});
}
}
上面的代码中,.excludePathPatterns() 方法接收一个数组,可以传入多个路径,这里传入了 "/login", "/register", "/logout" 三个路径,表示这三个路径不会被拦截器拦截。
原文地址: https://www.cveoy.top/t/topic/bcvC 著作权归作者所有。请勿转载和采集!