什么是servlet< load-on-startup>价值意味着 [英] What does the servlet <load-on-startup> value signify

查看:162
本文介绍了什么是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> 

根据我的理解,< load-on-startup>的值; 必须是一个正整数才能自动加载。我在谷歌上查了一下,但我遇到的回复只会增加我的困惑。

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 表示应该在Web应用程序启动时加载此servlet(实例化
并调用其
init())。此
元素的元素内容必须是一个整数,表示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&lt; load-on-startup&gt;价值意味着的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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