<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. Centos7搭建lamp环境

    首先安装apache Centos7默认已经安装httpd服务,只是没有启动. 如果需要重新安装,输入 yum install -y httpd 启动服务: systemctl start httpd ...

  2. (转)分布式文件存储FastDFS(五)FastDFS常用命令总结

    http://blog.csdn.net/xingjiarong/article/details/50561471 1.启动FastDFS tracker: /usr/local/bin/fdfs_t ...

  3. js 获取 鼠标位置 和获取元素位置

    ]; body.addEventListener("mousemove", outpostion); function outpostion() { console.log(&qu ...

  4. Appium 使用android_uiautomator定位元素时报错: The requested resource could not be found, or a request was received using an HTTP method that is not supported by the mapped resource

    使用 android_uiautomator 定位元素时(现在用的还不太熟,对于这个方法还需要加深了解)报错: 报错信息:The requested resource could not be fou ...

  5. mysql5.7初始化密码报错ERROR1820(HY000):YoumustresetyourpasswordusingALTERUSERstateme

    1,mysql5.6是密码为空直接进入数据库的,但是mysql5.7就需要初始密码 cat /var/log/mysqld.log | grep password 或者:grep 'temporary ...

  6. JavaFX桌面应用开发-鼠标事件和键盘事件

    鼠标相关事件的操作初始代码 package application; import javafx.application.Application;import javafx.event.ActionE ...

  7. hdu2012 素数判定【C++】

    素数判定 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  8. 【codeforces 801A】Vicious Keyboard

    [题目链接]:http://codeforces.com/contest/801/problem/A [题意] 一个字符串只由VK组成; 让你修改一个字符; 使得剩下的字符串里面子串VK的个数最大; ...

  9. 清北学堂模拟赛d7t1 消失的数字

    题目描述 现在,我的手上有 n 个数字,分别是 a1; a2; a3; :::; an.我现在需要删除其中的 k 个数字.当然我不希望随随便便删除,我希望删除 k个数字之后,剩下的 n - k 个数中 ...

  10. Linux imooc learning

    https://www.imooc.com/video/3529 Windows Vs Linux Linux: (other linux overall   https://onedrive.liv ...