load-on-startup 真实含义


用了那么久都没真正看过文档说load-on-startup 是什么意思的,今天偶然看到了这个问题,记录一下吧。 

这个标签的含义是指,容器启动时加载这个servlet的顺序,正常的取值范围是:负数,0-5,如果是负数或者没有这个标签,则容器在启动时不自动加载这个servlet,如果是0-5,则按照顺序加载这个servlet,执行初始化方法init()。数字是0-5,加载顺序也是0-5。下面是文档说明: 
The load-on-startup element indicates that this servlet should be loaded (instantiated and have its init() called) on the startup of the web application. The optional contents of these 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. 
posted @ 2009-08-24 15:00  六不朽  阅读(1706)  评论(0编辑  收藏  举报