servlet <load-on-startup> 做什么?价值意味着 [英] What does the servlet &lt;load-on-startup&gt; value signify

查看:11
本文介绍了servlet <load-on-startup> 做什么?价值意味着的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有点困惑.在我们的应用程序中,我们定义了一些 servlet.以下是其中一个 servlet 的 web.xml 摘录:

I am getting a bit confused here. In our application we are having a few servlets defined. Here is the excerpt from the web.xml for one of the servlets:

<servlet>
    <servlet-name>AxisServlet</servlet-name>
    <display-name>Apache-Axis Servlet</display-name>
    <servlet-class>com.foo.framework.axis2.http.FrameworkServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
</servlet> 

根据我的理解, 的值必须是正整数才能自动加载.我在 google 上查了一下,但我遇到的回答只会增加我的困惑.

As per my understanding the value for the <load-on-startup> has to be a positive integer in order for it to get loaded automatically. I looked up on google but the responses I came across only added to my confusion.

推荐答案

Resin 3.0 记录此行为:

load-on-startup 可以指定一个(可选的)整数值.如果值为 0 或更大,它指示加载 servlet 的顺序,编号较高的 servlet 将获得在编号较低的 servlet 之后加载.

load-on-startup can specify an (optional) integer value. If the value is 0 or greater, it indicates an order for servlets to be loaded, servlets with higher numbers get loaded after servlets with lower numbers.

JSP 3.1 规范 (JSR 340) 在第 14-160 页上说:

The JSP 3.1 spec (JSR 340) says this on page 14-160:

元素 load-on-startup 表明这个 servlet 应该被加载(实例化并有其init() 调用)在 Web 应用程序启动时.这个元素的内容元素必须是一个整数,指示 servlet 应该在其中的顺序加载.如果值为负整数,或者元素不存在,则容器可以随时选择加载 servlet.如果值为正整数或 0,容器必须像应用程序一样加载和初始化 servlet部署.容器必须保证用较低整数标记的 servlet在用更高整数标记的 servlet 之前加载.容器可以选择加载具有相同 load-on-startup 值的 servlet 的顺序.

The element load-on-startup indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the Web application. The element content of this element must be an integer indicating the order in which the servlet should be loaded. If the value is a negative integer, or the element is not present, the container is free to load the servlet whenever it chooses. If the value is a positive integer or 0, the container must load and initialize the servlet as the application is deployed. The container must guarantee that servlets marked with lower integers are loaded before servlets marked with higher integers. The container may choose the order of loading of servlets with the same load-on-startup value.

您可能不仅要检查 JSR,还要检查 Web 容器的文档.可能有差异

You probably want to check not only the JSR, but also the documentation for your web container. There may be differences

这篇关于servlet <load-on-startup> 做什么?价值意味着的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆