計算機程序虛擬的人生
          虛擬世界中的游魂
              對于web應用,spring提供了可配置的ApplicatonContext加載機制;加載器目前有兩種加載選擇:ContextLoaderListener和ContextLoaderServlet

              加載器目前有兩種選擇:ContextLoaderListener和ContextLoaderServlet。這兩者在功能上完全等同,只是一個是基于Servlet2.3版本中新引入的Listener接口實現,而另一個基于Servlet接口實現。開發中可根據目標Web容器的實際情況進行選擇。

          在web.xml中增加:
          <listener>
              <listener-class>
                   org.springframework.web.context.ContextLoaderListener
               </listener-class>
          </listener>
          -----------------------------------------------------------------
          <servlet>
                <servlet-name>context</servlet-name>
                <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
                <load-on-startup>1</load-on-startup>
          </servlet>
          通過以上配置,Web容器會自動加載/WEB-INF/applicationContext.xml初始化

          如果需要指定配置文件位置,可通過context-param加以指定
          <context-param>
                 <param-name>contextConfigLocation</param-name>
                 <param-value>/WEB-INF/myApplicationContext.xml</param-value>
          </context-param>

          posted on 2009-06-23 11:32 小兄弟(Robbins) 閱讀(210) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
           
          主站蜘蛛池模板: 萝北县| 略阳县| 瓮安县| 河源市| 宜兰县| 霞浦县| 三原县| 遂平县| 德阳市| 宝坻区| 新蔡县| 青龙| 铅山县| 孟津县| 高陵县| 方山县| 呼玛县| 晋城| 固安县| 巴马| 裕民县| 柯坪县| 喀喇| 竹溪县| 宜都市| 呼和浩特市| 汉川市| 宿松县| 久治县| 大渡口区| 临武县| 东乌珠穆沁旗| 保亭| 古蔺县| 津南区| 汪清县| 班玛县| 武乡县| 平和县| 醴陵市| 楚雄市|