Spring Boot 整合 swagger-bootstrap-ui 拦截器 问题解决
作者:互联网
配置拦截器时会禁用doc.html的接口地址
@Override
public void addInterceptors(InterceptorRegistry registry) {
InterceptorRegistration registration=registry.addInterceptor(studentHandlerInterceptor);
registration.addPathPatterns("/**")
.excludePathPatterns("/login")
.excludePathPatterns("/swagger-resources/**");
}
在拦截器中设置401认证错误状态码
String Authorization = httpServletRequest.getHeader("Authorization");
if (StringUtils.isBlank(Authorization)) {
httpServletResponse.setStatus(401);
return false;
}
标签:拦截器,excludePathPatterns,Spring,bootstrap,401,registration,swagger,Authorization 来源: https://blog.csdn.net/weixin_52008536/article/details/120593605