<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. Linux内存压力测试-memtester工具

    *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...

  2. 2015.12.25-2016.01.01 大论文迭代B

    大论文B轮迭代,稍重前端 12.25 周五,完善摘要 12.26 周六,完善第一章 12.27 周天,完善第二章 12.28 周一,完善第三章 12.29 周二,完善第四章 12.30 周三,完善第五 ...

  3. CSS (层叠样式表)

    层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言.CSS不仅可以静态 ...

  4. Java单元测试 - TestNG

    官网 Eclipse安装TestNG插件 与Junit相比 从Junit发展而来,开发者就是Junit小组的一个人 Test Suite不再需要硬编码,就像cf自动登录的脚本中一样,可以写到一个xml ...

  5. PHP 之二位数组根据某个字段排序封装

    /** * @param $array * @param $keys * @param string $sort * @return array */ function arraySort($arra ...

  6. ES6 中set的用法

  7. 如何从源码启动和编译IoTSharp

    IoTSharp 项目是一个开源物联网平台,数据库使用PostgreSQL , 后端使用 Asp.Net Core 2.2 ,前端使用  vue-element-admin , 下面我们介绍如何启动项 ...

  8. [LUOGU] 1108 低价购买

    统计本质不同的\(LIS\)个数. 因为本题要求的是\(N^2\)级别的算法,就直接暴力统计\(LIS\)的个数了 然后统计方案数的话加入发现有之间有一个值,以它为结尾的\(LIS\)长度和当前的相等 ...

  9. windows桌面远程工具连接Ubuntu

    1.Ubuntu安装:sudo apt-get install xrdp    sudo apt-get install vnc4server sudo apt-get install xubuntu ...

  10. 前端开发神器之chrome 综述

    作为前端工程师,也许你对chrome开发工具不陌生,但也谈不上对各个模块有深入了解. 本文主要是为chrome开发工具使用这个系列做个开篇. 参考资料: 谷歌开发者: https://develope ...