首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么Spring HandlerExecutionChain既有拦截器又有interceptorList?

为什么Spring HandlerExecutionChain既有拦截器又有interceptorList?
EN

Stack Overflow用户
提问于 2020-02-18 11:16:51
回答 1查看 137关注 0票数 1

为什么spring源码org.springframework.web.servlet.HandlerExecutionChain中会有数组类型的拦截器和列表类型的interceptorList?这有必要吗?

代码语言:javascript
复制
public class HandlerExecutionChain {

    private final Object handler;

    @Nullable
    private HandlerInterceptor[] interceptors;

    @Nullable
    private List<HandlerInterceptor> interceptorList;

    .....
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-18 15:37:05

当您查看the source code时,您将看到只有HandlerInterceptor[] interceptors仅在HandlerExecutionChain之外返回:

代码语言:javascript
复制
public HandlerInterceptor[] getInterceptors() {

您还可以查看用于创建List<HandlerInterceptor> interceptorListList<HandlerInterceptor> initInterceptorList(。它看起来像是interceptorList集合,它有助于创建稍后在外部公开的interceptors数组。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60273268

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档