<servlet>
<servlet-name>SystemInit</servlet-name>
<servlet-class>sjgl.system.SystemInitServlet</servlet-class>
<load-on-startup>10</load-on-startup>
</servlet>

之前一直以为,存在<servlet>标签,一定对应着<servlet-mapping>标签,今天才发现<servlet-mapping>是非必须的,<servlet>是初始化这个Servlet类。

在web.xml中配置servlet的时候会有个属性<load-on-startup></load-on-startup>,它的作用如下:

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 元素标记容器是否应该在web应用程序启动的时候就加载这个servlet(实例化并调用其init()方法)。
  2. 可选择值必须是一个整数,用来表示servlet被加载的先后顺序。
  3. 如果该元素的值为负数或没有设置,则容器会当Servlet被请求时再加载(懒加载)。
  4. 如果值为正整数或者0时,表示容器在应用启动时就加载并初始化这个servlet,值越小,servlet的优先级越高,就越先被加载。如果值相同时,容器就会顺序加载。

web.xml中load-on-startup的更多相关文章

  1. web.xml中load-on-startup的作用

    如下一段配置,熟悉DWR的再熟悉不过了:<servlet>   <servlet-name>dwr-invoker</servlet-name>   <ser ...

  2. 详解web.xml中元素的加载顺序

    一.背景 最近在项目中遇到了启动时出现加载service注解注入失败的问题,后来经过不懈努力发现了是因为web.xml配置文件中的元素加载顺序导致的,那么就抽空研究了以下tomcat在启动时web.x ...

  3. web.xml中load-on-startup的作用(转)

    web.xml中load-on-startup的作用 如下一段配置,熟悉DWR的再熟悉不过了:<servlet>   <servlet-name>dwr-invoker< ...

  4. 【转】web.xml中load-on-startup的作用

    http://www.blogjava.net/xzclog/archive/2011/09/29/359789.html 如下一段配置,熟悉DWR的再熟悉不过了:<servlet>   ...

  5. web.xml中load-on-startup的作用,web应用写一个InitServlet,这个servlet配置为启动时装载

    如下一段配置,熟悉DWR的再熟悉不过了:<servlet>   <servlet-name>dwr-invoker</servlet-name>   <ser ...

  6. java web开发中的奇葩事web.xml中context-param中的注释

    同事提交了代码.结果除同事之外,其他人全部编译报错.报错说web.xml中配置的一个bean 没有定义.按照报错提示,各种找,无果. 由于代码全部都是提交到svn主干,之前也没有做过备份,只能一步一步 ...

  7. (转)web.xml中的contextConfigLocation在spring中的作用

    (转)web.xml中的contextConfigLocation在spring中的作用   一.Spring如何使用多个xml配置文件 1.在web.xml中定义contextConfigLocat ...

  8. web.xml中welcome-file-list的作用

    今天尝试使用struts2+ urlrewrite+sitemesh部署项目,结果发现welcome-file-list中定义的欢迎页不起作用: <welcome-file-list> & ...

  9. servlet中用注解的方式读取web.xml中的配置信息

    在学习servletContext的时候,我们知道了可以在web.xml中通过<context-param>标签来定义全局的属性(所有servlet都能读取的信息),并在servlet中通 ...

随机推荐

  1. 用svg做流程管理

    说起流程管理这个功能,如果没有个动态图配合显示,简直就是太没有客户体验感了.就比如说请假流程吧,流程走到哪一步了,流程走向过程中都那些人审批的,审批的结果等等,如果就来个列表,也不是说不行,就是觉得太 ...

  2. 奇怪的print progname ":\n"日志

    [root@xxxxxxxx /home/ahao.mah] #tail /var/log/messages -f Feb 10 10:01:01 csaccurate-49-5011 } Feb 1 ...

  3. hdu 4018 Parsing URL(字符串截取)

    题目 以下引用自百度百科: sscanf 的相关用法 头文件:#include<stdio.h>     1. 常见用法. 1 2 3 charbuf[512]; sscanf(" ...

  4. 几校联考——day1题解

    T1 约数的个数(好像不可提交) 如果一个整数a能够整除整数b,那么a叫做b的约数.现在有N(1 <= N <= 100,000)个整数,对于其中的每一个数,请找出它在其余N - 1个整数 ...

  5. 利用open MP获取计算机核心数量的方法

    openMP是一款普遍通用的并行计算编程模型,使用它通常能够充分利用多核计算的优势. 以下是一种能够测试核心数量的方法: std::cout << "parallel begin ...

  6. pandas - 案例(股票分析)

    需求: 使用tushare包获取某股票的历史行情数据. 输出该股票所有收盘比开盘上涨3%以上的日期. 输出该股票所有开盘比前日收盘跌幅超过2%的日期. 假如我从2010年1月1日开始,每月第一个交易日 ...

  7. Ubuntu_linux系统与网络服务管理

    1.远程telnet联机:telnetd: 2.远程加密ssh联机:openssh: 3.webmin远程联机:webmin: 3.VNC远程图像界面控制:vino: 4.NAT网关服务器:iptab ...

  8. 5.2.2 re模块方法与正则表达式对象

    Python标准库re提供了正则表达式操作所需要的功能,既可以直接使用re模块中的方法,来实现,也可以把模式编译成正则表达式对象再使用. 方法 功能说明 complie(pattern[,flagss ...

  9. 【codeforces 796B】Find The Bone

    [题目链接]:http://codeforces.com/contest/796/problem/B [题意] 一开始骨头在1号位置; 然后有m个洞,给出洞的下标; 然后有k个交换操作; 如果骨头到洞 ...

  10. hdu 1220组合数学

    两个立方体相交的点数有0 1 2 4 不考虑相交点数的话有C(n,2)个立方对. 而求不超过两个交点的对数,即为用总的减去有四个交点的对数,而四个交点即为同面 四个交点的对数为相同的面的个数为(所有的 ...