在servlet的配置当中,<load-on-startup>5</load-on-startup>的含义是:

标记容器是否在启动的时候就加载这个servlet。

当值为0或者大于0时,表示容器在应用启动时就加载这个servlet;

当是一个负数时或者没有指定时,则指示容器在该servlet被选择时才加载。

正数的值越小,启动该servlet的优先级越高。

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.

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/enjoyo/archive/2007/08/27/1761033.aspx

EG:

<servlet>
    <servlet-name>LogIniter</servlet-name>
    <servlet-class>com.init.LogIniter</servlet-class>
    <init-param>
      <param-name>log4j</param-name>
      <param-value>/WEB-INF/log4j.properties</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

<servlet>
    <servlet-name>DicDataIniter</servlet-name>
    <servlet-class>com.init.DicDataIniter</servlet-class>
    <load-on-startup>2</load-on-startup>
  </servlet>

<servlet-mapping>
    <servlet-name>LogIniter</servlet-name>
    <url-pattern>/LogIniter</url-pattern>
  </servlet-mapping>

<servlet-mapping>
    <servlet-name>DicDataIniter</servlet-name>
    <url-pattern>/DicDataIniter</url-pattern>
  </servlet-mapping>

[转]Servlet的load-on-startup的更多相关文章

  1. Spring boot 全局配置文件application.properties

    #更改Tomcat端口号 server.port=8090 #修改进入DispatcherServlet的规则为:*.htmlserver.servlet-path=*.html#这里要注意高版本的s ...

  2. SpringBoot 全配置(推荐收藏)

    # =================================================================== # COMMON SPRING BOOT PROPERTIE ...

  3. SpringBoot 之 MVC

    SpringBoot MVC 和静态资源 首先,我们一定要搞清楚,mvc 配置和 static 配置的联系和区别. mvc 配置其实就是给 spring mvc 框架用的, 具体来说, 比如 @Req ...

  4. sprint boot 配置

    来源:https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-configure-to ...

  5. spring boot的默认配置

    # BANNER banner.charset=UTF- # Banner file encoding. banner.location=classpath:banner.txt # Banner f ...

  6. Servlet 工作原理解析

    转自:http://www.ibm.com/developerworks/cn/java/j-lo-servlet/ Web 技术成为当今主流的互联网 Web 应用技术之一,而 Servlet 是 J ...

  7. JavaWeb总结--Servlet 工作原理解析

    从 Servlet 容器说起 要介绍 Servlet 必须要先把 Servlet 容器说清楚,Servlet 与 Servlet 容器的关系有点像枪和子弹的关系,枪是为子弹而生,而子弹又让枪有了杀伤力 ...

  8. Servlet容器的启动过程

    [http://book.51cto.com/art/201408/448854.htm]   Tomcat的启动逻辑是基于观察者模式设计的,所有的容器都会继承Lifecycle接口,它管理着容器的整 ...

  9. [转]Servlet 工作原理解析

    Web 技术成为当今主流的互联网 Web 应用技术之一,而 Servlet 是 Java Web 技术的核心基础.因而掌握 Servlet 的工作原理是成为一名合格的 Java Web 技术开发人员的 ...

  10. Servlet 工作原理解析--转载

    原文:http://www.ibm.com/developerworks/cn/java/j-lo-servlet/index.html?ca=drs- Web 技术成为当今主流的互联网 Web 应用 ...

随机推荐

  1. perl6中的hash定义(1)

    ,,,); say %hash; , b => ); say %hash2; my %hash3 = (:name('root'), :host('localost')); say %hash3 ...

  2. vue-混入mixin

    混入 基础 混入 (mixins) 是一种分发 Vue 组件中可复用功能的非常灵活的方式.混入对象可以包含任意组件选项.当组件使用混入对象时,所有混入对象的选项将被混入该组件本身的选项. 例子: // ...

  3. python基础===理解Class的一道题

    解题如下: from random import randint class Die(): def __init__(self,sides=6): self.sides = sides def rol ...

  4. gunicorn 启动无日志

    gunicorn -c gunicorn_info.py info:app 接手整理老项目,发现有个服务迁移后启动不了,也没报错信息 修改gunicorn_info.py里的daemon = not ...

  5. js判断文件格式及大小

      //判断照片大小 function getPhotoSize(obj){     photoExt=obj.value.substr(obj.value.lastIndexOf(".&q ...

  6. Leetcode 之Flatten Binary Tree to Linked List(50)

    将左子树接到右子树之前,递归解决 void flatten(TreeNode *root) { if (root == nullptr)return; flatten(root->left); ...

  7. Leetcode 之Longest Valid Parentheses(39)

    有一定的难度.用堆栈记录下所有左符的位置,用变量记录下孤立右符的位置. int longestValidParentheses(const string& s) { stack<int& ...

  8. node自动调试

    supervisor 第一步:安装:npm -g install supervisor没有权限的时候可以sudo npm -g install supervisor 第二步:使用:supervisor ...

  9. vConsole ~ 移动开发调试工具

    在开发移动端项目时,有时候在PC端好好的,但是到了手机上出bug,很难调试,这时候可以用vConsole调试工具 使用方式 1.直接引入 <script src="vconsole.m ...

  10. netcore 配置文件使用

    一直在记录整理接口调用,但是最近发现关于项目在vs中本地启动也有许多方便的地方. 首先由于使用的是Java的Eureka和网关来做的服务基础, 然后服务就涉及到注册一说, 问题是,如果appsetti ...