posts - 82, comments - 269, trackbacks - 0, articles - 1
            BlogJava :: 首頁 :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理

          ?在web.xml設置監(jiān)聽器:org.springframework.web.context.ContextLoaderListener
          ?<listener>
          ??<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
          ?</listener>
          ?
          ?在此類(ContextLoaderListener)中有如下方法:?
          ?public void contextInitialized(ServletContextEvent event) {
          ??this.contextLoader = createContextLoader();
          ??this.contextLoader.initWebApplicationContext(event.getServletContext());
          ?}
          ?
          ?org.springframework.web.context.ContextLoader
          ?在此類中有如下變量:?public static final String CONTEXT_CLASS_PARAM = "contextClass";
          ????public static final String CONFIG_LOCATION_PARAM = "contextConfigLocation";

          ?
          ?如下方法:initWebApplicationContext,createWebApplicationContext
          ?第一個方法調(diào)用了第二個方法,第二個方法則通過如下代碼初始為了一個上下文環(huán)境
          ?String configLocation = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
          ?
          ?注:另外一點如下的DispatcherServlet設置會自動加載petstore-servlet.xml環(huán)境,原理我查了半天我也不知道怎么搞的.
          ?<servlet>
          ??<servlet-name>petstore</servlet-name>
          ??<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
          ??<load-on-startup>2</load-on-startup>
          ?</servlet>


          評論

          # re: Spring在Web中是如何載入相關(guān)的上下文環(huán)境  回復  更多評論   

          2006-12-22 08:22 by 壞男孩
          頂!??

          # re: Spring在Web中是如何載入相關(guān)的上下文環(huán)境  回復  更多評論   

          2006-12-22 09:34 by BeanSoft
          哈哈, 把源碼都查找一遍就 OK 了.

          # re: Spring在Web中是如何載入相關(guān)的上下文環(huán)境  回復  更多評論   

          2006-12-22 13:09 by xmlspy
          另外一點如下的DispatcherServlet設置會自動加載petstore-servlet.xml環(huán)境,原理我查了半天我也不知道怎么搞的.


          原因:

          spring默認加載 你的工程名稱-servlet.xml 文件,

          # re: Spring在Web中是如何載入相關(guān)的上下文環(huán)境  回復  更多評論   

          2006-12-22 19:15 by itspy
          @xmlspy


          spring默認加載 你的工程名稱-servlet.xml 文件

          這個我知道,我是想看看實現(xiàn)這段功能的代碼,但沒找到.

          # re: Spring在Web中是如何載入相關(guān)的上下文環(huán)境  回復  更多評論   

          2006-12-28 15:01 by baal
          其實都是classload,app server會在啟動時去先load這些類,凡是配置文件寫全類名的都這樣。哪些文件都是當參數(shù)傳進去,或放在固定地方。
          主站蜘蛛池模板: 天水市| 横峰县| 玛曲县| 阿拉善左旗| 寿光市| 松江区| 遵义市| 育儿| 策勒县| 建阳市| 韩城市| 康平县| 罗山县| 澄迈县| 宁明县| 潜江市| 贵州省| 孝感市| 龙岩市| 太仆寺旗| 镇宁| 乡宁县| 甘肃省| 海南省| 大同县| 洪雅县| 方正县| 大姚县| 馆陶县| 淅川县| 疏附县| 龙江县| 洛宁县| 砚山县| 永宁县| 平遥县| 邮箱| 武安市| 英吉沙县| 新建县| 滨海县|