spring boot 拦截器使用

mac2026-09-27  8

InterceptorConfig.java

@Configuration public class InterceptorConfig implements WebMvcConfigurer { @Autowired LoginInterceptor loginInterceptor; @Value("${intercept.url}") String interceptURL; /** * 注册自定义拦截器 */ @Override public void addInterceptors(InterceptorRegistry registry) { //排除登录请求 String []urls = interceptURL.split(","); List<String> urlList =new ArrayList<>(Arrays.asList(urls)); registry.addInterceptor(loginInterceptor).excludePathPatterns(urlList); } }

 

最新回复(0)