gpt4 book ai didi

java - 为什么在加载 webapp 时由 tomcat 容器在启动时自动创建监听器和过滤器实例?

转载 作者:行者123 更新时间:2023-11-29 00:01:43 27 4
gpt4 key购买 nike

我想知道在Tomcat容器加载webapp后创建listener和filter实例的原因。为什么在 Servlet API 中指定预加载而不是延迟加载?

最佳答案

自动实例化行为是所有 Servlet 容器都必须遵守的 servlet 规范的一部分。

你可以在这里查看http://download.oracle.com/otndocs/jcp/servlet-3.0-fr-oth-JSpec/

下载 PDF。

6.2.1 Filter Lifecycle

After deployment of the Web application, and before a request causes the container to access a Web resource, the container must locate the list of filters that must be applied to the Web resource as described below. The container must ensure that it has instantiated a filter of the appropriate class for each filter in the list, and called its init(FilterConfig config) method.

11.2 Event Listeners

Application event listeners are classes that implement one or more of the servlet event listener interfaces. They are instantiated and registered in the Web container at the time of the deployment of the Web application. They are provided by the Developer in the WAR.

关于java - 为什么在加载 webapp 时由 tomcat 容器在启动时自动创建监听器和过滤器实例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39361678/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com