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

          ?在web.xml設(shè)置監(jiān)聽(tīng)器: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
          ?第一個(gè)方法調(diào)用了第二個(gè)方法,第二個(gè)方法則通過(guò)如下代碼初始為了一個(gè)上下文環(huán)境
          ?String configLocation = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
          ?
          ?注:另外一點(diǎn)如下的DispatcherServlet設(shè)置會(huì)自動(dòng)加載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>


          評(píng)論

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

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

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

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

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

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


          原因:

          spring默認(rèn)加載 你的工程名稱-servlet.xml 文件,

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

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


          spring默認(rèn)加載 你的工程名稱-servlet.xml 文件

          這個(gè)我知道,我是想看看實(shí)現(xiàn)這段功能的代碼,但沒(méi)找到.

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

          2006-12-28 15:01 by baal
          其實(shí)都是classload,app server會(huì)在啟動(dòng)時(shí)去先load這些類,凡是配置文件寫全類名的都這樣。哪些文件都是當(dāng)參數(shù)傳進(jìn)去,或放在固定地方。
          主站蜘蛛池模板: 子洲县| 闵行区| 靖江市| 杭州市| 株洲县| 屏东市| 徐水县| 木里| 门头沟区| 石楼县| 金塔县| 津市市| 远安县| 五台县| 夹江县| 广灵县| 武隆县| 香港| 晋宁县| 济宁市| 泸西县| 社会| 金乡县| 西乌| 房山区| 临泉县| 江永县| 延川县| 平利县| 乌恰县| 张掖市| 泾川县| 昌黎县| 舟曲县| 洛扎县| 南平市| 湘西| 武宁县| 辽宁省| 河池市| 张家港市|