1. 程式人生 > >web.xml中load-on-startup的含義

web.xml中load-on-startup的含義

在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.

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>

相關推薦

web.xmlload-on-startup含義

在servlet的配置當中,<load-on-startup>5</load-on-startup>的含義是: 標記容器是否在啟動的時候就載入這個servlet。 當值為0或者大於0時,表示容器在應用啟動時就載入這個servlet; 當是一個負數時或者

web.xmlload-on-startup的作用

如下一段配置,熟悉DWR的再熟悉不過了:<servlet>   <servlet-name>dwr-invoker</servlet-name>   <servlet-class>org.directwebremoting.s

web.xmlload-on-startup的作用(新解)

1、load-on-startup元素標記容器是否在啟動的時候就載入這個servlet(例項化並呼叫其init()方法)。 2、它的值必須是一個整數,表示servlet應該被載入的順序 3、當值為0或者大於0時,表示容器在應用啟動時就載入並初始化這個servlet; 4、當值小於0或者沒有指定時,則

【轉載】web.xmlload-on-startup的作用

轉載地址:http://www.blogjava.net/xzclog/archive/2011/09/29/359789.html 如下一段配置,熟悉DWR的再熟悉不過了: < servlet > < servlet-name&g

servlet開發web.xmlload-on-start標籤作用

web.xml中<load-on-start>n</load-on-satrt>作用   如下面一段配置,我們再熟悉不過了:      我們注意到它裡面包含了這段配置:<load-on-startup>1</load-on-startup&g

web.xmlservlet配置及其含義

客戶端 utf day style xsd 4.0 tomcat服務 -i org 1 <?xml version="1.0" encoding="UTF-8"?> 2 <web-app xmlns="http://xmlns.jcp.org/xml

web.xml配置的classpath含義

  <context-param>    <param-name>webAppRootKey</param-name>    <param-value>webApp.root</param-value>  <

web.xml spring-servlet.xml 和 application.xml 配置位置及含義

在我們進行 Spring-servlet 進行開發的時候,經常會遇到配置檔案配置的問題,要徹底的解決這個問題,我們需要了解 springMVC 設計的基本架構 1.SpringMVC 的配置分為兩部分 application.xml 和 spring-servl

java web 使用load-on-startup標籤建立跟隨Tomcat同時執行的類

在一個小的專案當中,需要一個類在tomcat 啟動時跟隨Tomcat一同啟動並執行。在伺服器開始就開始,在伺服器結束就結束。 第一次想到的是在jsp頁面嵌入java程式碼,使用並不友好,需要訪問才可以執行java類。 現在使用另一種方法進行啟動java 類 建立一個serv

web.xml的ServletContextListener

data- not fileinput 否則 new .info 自己 dsm getattr 要想了解ServletContextListener,先看看web.xml中的<listener>配置。 一)web.xml中的內容載入順序: 首

web.xml配置spring監聽器和spring配置文件位置

nco erl spring XML param onf ati spa extc <!-- spring配置文件位置 --> <context-param> <param-name>contextConfigLocation</

web.xml的url-pattern映射規則

都沒有 oca 路徑 color 進行 例子 方便 解析 所有 Servlet和filter是J2EE開發中常用的技術,使用方便,配置簡單。servlet和filter中的url-pattern有一些文章在裏面的,總結了一些東西,以免遇到問題又要浪費時間。 一,ser

配置struts時web.xml<url-pattern>*.action</url-pattern>

names val put eth package pan 評論 dispatch mce <filter> <filter-name>struts2</filter-name> <filter-class>org

web.xml的dispatchservlet後,js,css,甚至gif都不能正常顯示

startup view details article 的人 核心 默認 href com 這個可以說是很多初學Springmvc的人都會碰到一個令人頭痛的問題 那就是為什麽我配置好web.xml中的dispatchservlet後,js,css,甚至gif都不能正常顯示

web.xml async-supported爆紅叉叉 cvc-complex-type.2.4.a: Invalid content was found starting with element 'async-supported'.

class 表頭 start lex .org nco app lns pri 新建一個項目在web.xml中些東西是發現async-supported報紅叉 cvc-complex-type.2.4.a: Invalid content was found starti

Web.xml metadata-complete 介紹

配置 works XML get evel developer 同時 講解 部署 Servlet 3.0 的部署描述文件 web.xml 的頂層標簽 <web-app> 有一個 metadata-complete 屬性, 該屬性指定當前的部署描述文件是否是完全的

服務器啟動時Webapp的web.xml配置的加載順序

結點 得到 類型 man authent 一個tomcat web www conf 一 1、啟動一個WEB項目的時候,WEB容器會去讀取它的配置文件web.xml,讀取<listener>和<context-param>兩個結點。 2、緊急著,

web.xml<web-app>提示The content of element type "web-app" must match "(icon?,display- name?,description?,distributable?,

session span text .com ble splay 錯誤 esc gin 錯誤:配置web.xml時,出現紅色叉叉,提示 The content of element type "web-app" must match "(icon?,display-

Web.xmlFilter過濾器標簽幾個說明

name 網上 spa 路徑 class 地址 web 例子 -m 在研究liferay框架中看到Web.xml中加入了過濾器的標簽,可以根據頁面提交的URL地址進行過濾,發現有幾個新標簽沒用過,下面就介紹以下幾個過濾器的標簽用法: <!-- 定義Filte

IDEA導入maven工程以及web.xmlspring配置文件文件加載不到的問題

tom gpo 使用 選擇 spring配置 http war 文件中 ext 使用idea導入maven工程,工程只留了src和pom.xml文件 1、從打開idea中導入:File ----> New -----> Project from Exist