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

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

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

    隨筆-314  評(píng)論-209  文章-0  trackbacks-0
    如下一段配置,熟悉DWR的再熟悉不過(guò)了:
    <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>,那么這個(gè)配置有什么作用呢?

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

    翻譯過(guò)來(lái)的意思大致如下:
    1)load-on-startup元素標(biāo)記容器是否在啟動(dòng)的時(shí)候就加載這個(gè)servlet(實(shí)例化并調(diào)用其init()方法)。

    2)它的值必須是一個(gè)整數(shù),表示servlet應(yīng)該被載入的順序

    2)當(dāng)值為0或者大于0時(shí),表示容器在應(yīng)用啟動(dòng)時(shí)就加載并初始化這個(gè)servlet;

    3)當(dāng)值小于0或者沒(méi)有指定時(shí),則表示容器在該servlet被選擇時(shí)才會(huì)去加載。

    4)正數(shù)的值越小,該servlet的優(yōu)先級(jí)越高,應(yīng)用啟動(dòng)時(shí)就越先加載。

    5)當(dāng)值相同時(shí),容器就會(huì)自己選擇順序來(lái)加載。

    所以,<load-on-startup>x</load-on-startup>,中x的取值1,2,3,4,5代表的是優(yōu)先級(jí),而非啟動(dòng)延遲時(shí)間。

    如下題目:

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

    a.默認(rèn)起始頁(yè)

    b.servlet啟動(dòng)延遲時(shí)間定義

    c.error處理頁(yè)面

    d.jsp文件改動(dòng)后重新載入時(shí)間

    答案:b,d

    通常大多數(shù)Servlet是在用戶第一次請(qǐng)求的時(shí)候由應(yīng)用服務(wù)器創(chuàng)建并初始化,但<load-on-startup>n</load-on-startup>   可以用來(lái)改變這種狀況,根據(jù)自己需要改變加載的優(yōu)先級(jí)!

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

    評(píng)論:
    # re: web.xml中l(wèi)oad-on-startup的作用 2012-07-24 11:01 | Servlet-BB
    受教了。。。贊一個(gè)。。。  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2012-09-17 10:34 | 李恒
    說(shuō)的很詳細(xì),理解很深刻,謝謝。  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2012-11-15 18:13 | 34243
    234234324  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2012-11-30 11:06 | zhuxian
    看了解釋,茅塞頓開,謝謝了  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2013-04-08 13:11 | 三雙
    很詳細(xì)  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2013-04-10 17:17 | Matt
    講得不錯(cuò)!!  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2013-07-20 17:51 | 小劉
    C。error處理頁(yè)面
    WEB.XML里面應(yīng)該沒(méi)有吧?  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2013-08-06 19:31 | prince
    @小劉
    這個(gè)真的有   回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2013-08-08 19:35 | 香港792
    醍醐灌頂  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2013-08-19 14:54 | 小楊
    很詳細(xì)  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2013-09-04 09:57 | jason
    翻譯的第3條有些不完善,正確應(yīng)該是當(dāng)為負(fù)數(shù)或沒(méi)有值時(shí),可以由server容器自行決定何時(shí)load該servlet. 句中的it應(yīng)該指的是container而不是servlet.  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2014-04-22 16:52 | aaa
    樓上正解,為負(fù)數(shù)或沒(méi)有值時(shí),不一定是servlet被調(diào)用才加載  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2014-07-15 17:03 | 辛丶
    看得很明白。謝謝  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2014-08-18 15:11 | xiaoliu
    heihiehiehiehie  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2014-08-22 07:53 | 瘋狂燃燒的歲月
    很好 受教  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2014-11-06 11:15 | daniel
    臥槽這段英文太給力了!64個(gè)贊!  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2015-03-30 14:26 | yy
    寫的很好,受教了  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2015-04-07 15:28 | 動(dòng)漫之賈
    很棒!多謝樓主分享!  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2015-04-14 10:35 | lili
    很好,多謝樓主分享!!  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2015-09-25 10:33 | Jason Wong
    # re: web.xml中l(wèi)oad-on-startup的作用[未登錄](méi) 2016-07-12 15:00 | Justin
    很詳細(xì) very good  回復(fù)  更多評(píng)論
      
    # re: web.xml中l(wèi)oad-on-startup的作用 2016-07-25 16:24 | coco
    釋疑了,剛跟同事就servlet能否不通過(guò)調(diào)用直接初始化問(wèn)題討論了一下  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 成人免费一区二区无码视频| 亚洲AV色欲色欲WWW| 国产一级淫片免费播放电影| 亚洲AV福利天堂一区二区三| 国内精品免费久久影院| 18禁无遮挡无码国产免费网站| 免费无码A片一区二三区 | 免费又黄又硬又爽大片| 亚洲av日韩av永久在线观看| 国内大片在线免费看| 亚洲精品久久无码| 成年人在线免费看视频| 久久久久久久尹人综合网亚洲| 亚洲91精品麻豆国产系列在线| 美女被免费视频网站| 亚洲AV无码之日韩精品| 一区二区三区免费视频网站 | 午夜国产精品免费观看| 人人狠狠综合久久亚洲高清| 亚洲成色www久久网站夜月| 国产麻豆一精品一AV一免费| 久久亚洲AV成人出白浆无码国产| 蜜桃视频在线观看免费视频网站WWW| 337p日本欧洲亚洲大胆艺术| 两个人的视频高清在线观看免费 | 亚洲AV无码国产在丝袜线观看| 亚洲国产精品99久久久久久| 国产乱人免费视频| 99热在线日韩精品免费| 亚洲精品在线免费观看视频| 两个人看的www免费| 久久国产亚洲精品无码| 24小时免费直播在线观看| 日韩毛片免费一二三| 日本高清免费不卡视频| 中文字幕永久免费视频| 亚洲导航深夜福利| 黄+色+性+人免费| 国产亚洲成av人片在线观看| a级亚洲片精品久久久久久久| 最近高清中文字幕免费|