web.xml中load-on-startup的作用(转)
如下一段配置,熟悉DWR的再熟悉不过了:
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>
我们注意到它里面包含了这段配置:<load-on-startup>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应该被载入的顺序
2)当值为0或者大于0时,表示容器在应用启动时就加载并初始化这个servlet;
3)当值小于0或者没有指定时,则表示容器在该servlet被选择时才会去加载。
4)正数的值越小,该servlet的优先级越高,应用启动时就越先加载。
5)当值相同时,容器就会自己选择顺序来加载。
所以,<load-on-startup>x</load-on-startup>,中x的取值1,2,3,4,5代表的是优先级,而非启动延迟时间。
如下题目:
2.web.xml中不包括哪些定义(多选)
a.默认起始页
b.servlet启动延迟时间定义
c.error处理页面
d.jsp文件改动后重新载入时间
答案:b,d
通常大多数Servlet是在用户第一次请求的时候由应用服务器创建并初始化,但<load-on-startup>n</load-on-startup> 可以用来改变这种状况,根据自己需要改变加载的优先级!
web.xml中load-on-startup的作用(转)的更多相关文章
- web.xml中<welcome-file-list>标签不起作用
之前也都提到过,web.xml会通过<servlet>和<servlet-mapping>来确定url和指定contoller文件,乃至于jsp页面的联系. 但是有一个< ...
- web.xml中的welcome-file-list不起作用
今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...
- web.xml中welcome-file-list的作用
今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...
- 【Servlet】web.xml中welcome-file-list的作用
今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...
- web.xml中load-on-startup的作用
如下一段配置,熟悉DWR的再熟悉不过了:<servlet> <servlet-name>dwr-invoker</servlet-name> <ser ...
- 【转】web.xml中load-on-startup的作用
http://www.blogjava.net/xzclog/archive/2011/09/29/359789.html 如下一段配置,熟悉DWR的再熟悉不过了:<servlet> ...
- web.xml中load-on-startup的作用,web应用写一个InitServlet,这个servlet配置为启动时装载
如下一段配置,熟悉DWR的再熟悉不过了:<servlet> <servlet-name>dwr-invoker</servlet-name> <ser ...
- (转)web.xml中的contextConfigLocation在spring中的作用
(转)web.xml中的contextConfigLocation在spring中的作用 一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocat ...
- web.xml 中配置了error-page但不起作用问题
问题: 在web.xml 中配置了 error-page,但是好像不起作用,就是跳转不到指定的页面. 配置信息如下: <!-- 400错误 --> <error-page> & ...
随机推荐
- UVALive6571 It Can Be Arranged(最小路径覆盖)
题意:现在有n个课程,每个课程有一定的参与人数,然后每个课程有开始时间和结束时间ai,bi. 而且给定了一个矩阵clean(ij),表示的是上完i课程需要clean[i][j]的时间打扫卫生才能继续上 ...
- KMP模板,最小循环节
(可以转载,但请注明出处!) 下面是有关学习KMP的参考网站 http://blog.csdn.net/yaochunnian/article/details/7059486 http://blog. ...
- 使用git了解代码编写过程
在看教程时,有的老师会将代码放到github,如果不想跟着视频一步一步来,那就直接clone整个代码,但整个看着又有点蒙,那就使用版本切换的功能了. 首先 git clone 下载下来 git log ...
- HDU 1548 A strange lift (Dijkstra)
A strange lift http://acm.hdu.edu.cn/showproblem.php?pid=1548 Problem Description There is a strange ...
- $("#id a") - $("#id .c a") = ?
前沿 这是之前淘宝的一道面试题,题目借用了 jQuery 选择器的语法.大概的意思是,从 #id 元素内选出所有不是 .c 后代的 a 元素,即父元素 #id 内的所有后代元素中,选出不是 .c 后代 ...
- github研究
一个程序猿一定会用git,但是我还没怎么用过,平时真是懒啊,学习之!...
- 使用dnsmasq快速搭建内网DNS
背景介绍公司有一批测试服务器,之间希望通过自定义的域名进行访问,这样比较方便,但每个人每台机器都维护一个hosts的话会非常麻烦,于是想搭建一个内部的DNS服务器,对自定义的域名进行解析,同时缓存公网 ...
- online judge 提交代码应该注意的事项
首先,eclipse工程上出现红色的惊叹号,这个时候一般是工程的参考library或者build path的jar文件或者库文件缺失,可以右键工程,打开properties,点击 java build ...
- MCU晶体旁边电容的作用及振荡电路的分析
绝大多数的MCU爱好者对MCU晶体两边要接一个22pF附近的电容不理解,因为这个电容有些时候是可以不要的.参考很多书籍,讲解的很少,往往提到最多的是起稳定作用,负载电容之类的话,都不是很深入理论的分析 ...
- 8天学通MongoDB
随笔分类 - MongoDB 双十一来了,别让你的mongodb宕机了 摘要: 好久没过来吹牛了,前段时间一直赶项目,没有时间来更新博客,项目也终于赶完了,接下来就要面临双十一这场惊心动魄的处女秀考验 ...