springboot 拦截器
作者:
我喝岩浆 | 来源:发表于
2020-05-27 10:26 被阅读0次
拦截器定义
@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/");
}
}
本文标题:springboot 拦截器
本文链接:https://www.haomeiwen.com/subject/dxoiahtx.html
网友评论