*代表只拦截一层,**代表拦截任意层。
一、*
如下是一个拦截器的配置,代表拦截**/video/**下一层的请求。
localhost/video/1 会进入此拦截器
localhost/video/mp4/1 不会进入
@Configuration
public class CheckInterceptorConfig implements WebMvcConfigurer{
@Autowired
private CheckInterceptor check;
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(check).addPathPatterns("/video/*");
}
}
二、**
如下拦截器的配置,代表拦截**/video/**下任意层的请求。
localhost/video/1 会进入此拦截器
localhost/video/mp4/1 也会进入
localhost/video/mp4/1080p/1 也会进入
@Configuration
public class CheckInterceptorConfig implements WebMvcConfigurer{
@Autowired
private CheckInterceptor check;
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(check).addPathPatterns("/video/**");
}
}