web.xml中load-on-startup分解转载
原创作者:邹凤丽,微博:zrunker,邮箱: zrunker@yahoo.com ,微信公众号:BookGuestCreation,个人平台: www.ibooker.cc 。

书客创作
在设置web.xml当时,在
首先看看这个元素的正确用法:这样###位置
test-dispatcher
org.springframework.web.servlet.DispatcherServlet
contextConfigLocation
classpath:spring/spring-*.xml
### 1 ###
< load-on-startup>元素在这里到底做什么?
官方解释:
Servlet specification:
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-start-up value.
翻译的意思大致如下:
(1)、load-on-startup元素标签容器是否在启动时加载此内容?servlet(实例化并调用其init()方法)。
(2),其值必须是整数,表示servlet加载顺序。
(3),当值为0或者大于0指示容器在应用程序启动时加载并初始化此。servlet。
(4),当值小于0或者如果未指定,则表示容器位于servlet仅在选中时加载。
(5)正数的值越小,servlet优先级越高,应用程序启动时加载的时间越早。
(6),当值相同时,容器将选择自己的加载顺序。
所以,x,中x的取值0,1,2,3,4,5表示优先级,而不是启动延迟时间。
作者:我没话说
链接:https://www.jianshu.com/p/c59ab1a0213b
资料来源:简介
这本简介书的版权归作者所有。请联系作者以获得授权,并注明任何形式的转载来源。
版权声明
所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除
itfan123




