拦截器定义
@Configuration
@AllArgsConstructor
public class InterceptorConfig extends WebMvcConfigurationSupport {
@Autowired
private MyHttpInterceptor myHttpInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(myHttpInterceptor).addPathPatterns("/**")
.excludePathPatterns("/user/login")
//避免swagger 打不开
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");;
}
@Override
protected void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("swagger-ui.html")
.addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
网友评论