<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-314  評論-209  文章-0  trackbacks-0
    如下一段配置,熟悉DWR的再熟悉不過了:
    <servlet>
       <servlet-name>dwr-invoker</servlet-name>
       <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
       <init-param>
        <param-name>debug</param-name>
        <param-value>true</param-value>
       </init-param>
       <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
       <servlet-name>dwr-invoker</servlet-name>
       <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

    我們注意到它里面包含了這段配置:<load-on-startup>1</load-on-startup>,那么這個配置有什么作用呢?

    貼一段英文原汁原味的解釋如下:
    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.

    翻譯過來的意思大致如下:
    1)load-on-startup元素標記容器是否在啟動的時候就加載這個servlet(實例化并調用其init()方法)。

    2)它的值必須是一個整數,表示servlet應該被載入的順序

    2)當值為0或者大于0時,表示容器在應用啟動時就加載并初始化這個servlet;

    3)當值小于0或者沒有指定時,則表示容器在該servlet被選擇時才會去加載。

    4)正數的值越小,該servlet的優先級越高,應用啟動時就越先加載。

    5)當值相同時,容器就會自己選擇順序來加載。

    所以,<load-on-startup>x</load-on-startup>,中x的取值1,2,3,4,5代表的是優先級,而非啟動延遲時間。

    如下題目:

    2.web.xml中不包括哪些定義(多選)

    a.默認起始頁

    b.servlet啟動延遲時間定義

    c.error處理頁面

    d.jsp文件改動后重新載入時間

    答案:b,d

    通常大多數Servlet是在用戶第一次請求的時候由應用服務器創建并初始化,但<load-on-startup>n</load-on-startup>   可以用來改變這種狀況,根據自己需要改變加載的優先級!

    posted on 2011-09-29 15:22 xzc 閱讀(149947) 評論(22)  編輯  收藏 所屬分類: WebJava

    評論:
    # re: web.xml中load-on-startup的作用 2012-07-24 11:01 | Servlet-BB
    受教了。。。贊一個。。。  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2012-09-17 10:34 | 李恒
    說的很詳細,理解很深刻,謝謝。  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2012-11-15 18:13 | 34243
    234234324  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2012-11-30 11:06 | zhuxian
    看了解釋,茅塞頓開,謝謝了  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2013-04-08 13:11 | 三雙
    很詳細  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2013-04-10 17:17 | Matt
    講得不錯!!  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2013-07-20 17:51 | 小劉
    C。error處理頁面
    WEB.XML里面應該沒有吧?  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2013-08-06 19:31 | prince
    @小劉
    這個真的有   回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2013-08-08 19:35 | 香港792
    醍醐灌頂  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2013-08-19 14:54 | 小楊
    很詳細  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2013-09-04 09:57 | jason
    翻譯的第3條有些不完善,正確應該是當為負數或沒有值時,可以由server容器自行決定何時load該servlet. 句中的it應該指的是container而不是servlet.  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2014-04-22 16:52 | aaa
    樓上正解,為負數或沒有值時,不一定是servlet被調用才加載  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2014-07-15 17:03 | 辛丶
    看得很明白。謝謝  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2014-08-18 15:11 | xiaoliu
    heihiehiehiehie  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2014-08-22 07:53 | 瘋狂燃燒的歲月
    很好 受教  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2014-11-06 11:15 | daniel
    臥槽這段英文太給力了!64個贊!  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2015-03-30 14:26 | yy
    寫的很好,受教了  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2015-04-07 15:28 | 動漫之賈
    很棒!多謝樓主分享!  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2015-04-14 10:35 | lili
    很好,多謝樓主分享!!  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2015-09-25 10:33 | Jason Wong
    good  回復  更多評論
      
    # re: web.xml中load-on-startup的作用[未登錄] 2016-07-12 15:00 | Justin
    很詳細 very good  回復  更多評論
      
    # re: web.xml中load-on-startup的作用 2016-07-25 16:24 | coco
    釋疑了,剛跟同事就servlet能否不通過調用直接初始化問題討論了一下  回復  更多評論
      
    主站蜘蛛池模板: 亚洲aⅴ无码专区在线观看春色| 亚洲人和日本人jizz| 免费精品视频在线| 五月婷婷亚洲综合| 一级毛片免费毛片毛片| 亚洲中文字幕无码日韩| 久久久久久久久久久免费精品| 国产中文在线亚洲精品官网| 国产午夜精品理论片免费观看| 亚洲国产综合无码一区| 在线毛片片免费观看| 亚洲综合国产精品| 成年午夜视频免费观看视频| 亚洲AV永久无码天堂影院| jizzjizz亚洲| 暖暖日本免费中文字幕| 亚洲欧洲国产精品久久| 免费无遮挡无码视频网站| 全部一级一级毛片免费看| 国产AV无码专区亚洲AV毛网站 | 亚洲阿v天堂在线| 最近免费中文字幕mv电影| 99热亚洲色精品国产88| 国产精品嫩草影院免费| 一个人免费观看日本www视频| 亚洲成av人在线视| 成人免费福利电影| 丝袜足液精子免费视频| 亚洲精品国产免费| 亚洲国产成人久久精品99| 美女被cao网站免费看在线看| 亚洲日本va在线观看| 亚洲国产精品成人一区| 99re在线视频免费观看| 亚洲欧洲精品成人久久曰| 亚洲色婷婷综合久久| 成人人观看的免费毛片| 一个人看的在线免费视频| 亚洲an日韩专区在线| 亚洲自偷自偷偷色无码中文| 国产99视频精品免费观看7|