修改成这样
@Configuration
public class HeaderTokenInterceptor implements WebMvcConfigurer {
@Autowired
SecurityInterceptor securityInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
InterceptorRegistration adminInterceptor = registry.addInterceptor(securityInterceptor);
adminInterceptor.excludePathPatterns("/admin/login")
.excludePathPatterns("/adminlogs/log")
.excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v2/**", "/swagger-ui.html/**");
//拦截所有路径
adminInterceptor.addPathPatterns("/admin/**");
}
}
@Configuration
public class SecurityInterceptor implements HandlerInterceptor {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
}
文档信息
- 本文作者:slience_me
- 本文链接:https://slienceme.xyz/2022/01/19/HandlerInterceptorAdapter%E5%92%8CWebMvcConfigurer%E8%BF%87%E6%97%B6/
- 版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)