Web请求拦截器
2022-11-02 本文已影响0人
Alen_ab56
1. 实现HandlerInterceptor;
@Component
public class HttpInterceptor implements HandlerInterceptor {}
2. 添加到拦截器链中;
@Component
public class WebMvcConfig implements WebMvcConfigurer {
@Autowired
private HttpInterceptor httpInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(httpInterceptor);
}