为什么spring源码中有数组类型拦截器和列表类型拦截器Listorg.springframework.web.servlet.HandlerExecutionChain
?有这个必要吗?
public class HandlerExecutionChain {
private final Object handler;
@Nullable
private HandlerInterceptor[] interceptors;
@Nullable
private List<HandlerInterceptor> interceptorList;
.....
}
最佳答案
当你查看the source code时你会看到只有 HandlerInterceptor[] interceptors
仅在 HandlerExecutionChain
之外返回在:
public HandlerInterceptor[] getInterceptors() {
您还可以查看List<HandlerInterceptor> initInterceptorList(
用于创建 List<HandlerInterceptor> interceptorList
。它看起来像 interceptorList
是有助于创建 interceptors
的集合稍后暴露在外的数组。
关于java - 为什么Spring HandlerExecutionChain同时有拦截器和interceptorList?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60273268/