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

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

          在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) 閱讀(206) 評論(0)  編輯  收藏

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


          網(wǎng)站導(dǎo)航:
           
           
          主站蜘蛛池模板: 横山县| 全州县| 定安县| 视频| 龙胜| 公安县| 渭南市| 承德县| 钟祥市| 宜君县| 庆城县| 滦平县| 星座| 东乡| 甘德县| 融水| 高要市| 双流县| 旌德县| 河东区| 二手房| 墨脱县| 泾阳县| 马鞍山市| 兴和县| 深水埗区| 白银市| 岳阳县| 铁岭县| 白玉县| 徐汇区| 会东县| 鹤岗市| 竹溪县| 尚义县| 含山县| 邵武市| 汕头市| 泸州市| 名山县| 鲁甸县|