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

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


          網站導航:
           
           
          主站蜘蛛池模板: 郯城县| 汨罗市| 西乌珠穆沁旗| 高阳县| 和平区| 昭通市| 朝阳区| 炎陵县| 盘山县| 康平县| 闽清县| 扶绥县| 特克斯县| 淮南市| 获嘉县| 望谟县| 普定县| 兰坪| 四子王旗| 广丰县| 桦川县| 新河县| 林口县| 苗栗市| 马龙县| 张家界市| 会昌县| 弥渡县| 远安县| 浦城县| 富蕴县| 台前县| 灵武市| 松阳县| 太白县| 潞城市| 广州市| 乐山市| 甘谷县| 南开区| 张家口市|