計算機程序虛擬的人生
          虛擬世界中的游魂
              對于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)  編輯  收藏

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


          網站導航:
           
           
          主站蜘蛛池模板: 湟中县| 噶尔县| 祁连县| 尼勒克县| 治多县| 濮阳县| 全南县| 延安市| 盱眙县| 蓬莱市| 东安县| 英德市| 临沧市| 靖远县| 临沂市| 瑞安市| 蒙城县| 琼海市| 宿松县| 胶南市| 常州市| 尚义县| 凤冈县| 电白县| 通榆县| 镇雄县| 成都市| 沈阳市| 凤冈县| 南汇区| 蓬安县| 西乌| 巨野县| 简阳市| 清原| 枣强县| 长宁区| 咸丰县| 汕尾市| 封开县| 丰顺县|