拦截器的执行顺序

2024-06-22 08:59:40 浏览数 (4)

翻看源码: registry.addInterceptor()

代码语言:javascript复制
    public InterceptorRegistration addInterceptor(HandlerInterceptor interceptor) {
        InterceptorRegistration registration = new InterceptorRegistration(interceptor);
        this.registrations.add(registration);
        return registration;
    }

imageimage

其中 order 的值越大执行的优先级越低

例如:registry.addInterceptor(new RefreshTokenInterceptor(stringRedisTemplate)).addPathPatterns("/**").order(0);

1 人点赞