1. 程式人生 > >spring 父子容器的概念,入門部落格推薦。必看

spring 父子容器的概念,入門部落格推薦。必看

-------------------------------------------------20160519更新-----------------------------------------

    1.1  ContextLoaderListener spring容器 根上下文(可以作為  父容器 ApplicationContext) 

    1.2 servlet裡init-param 比如springmvc配置(子容器)

    1.3 舉例 web.xml

   <!--父 -->
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>classpath:spring/applicationContext*.xml</param-value>
	</context-param>
	<listener>
		<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
	</listener>

	 <!--子 -->
    <servlet>
		<servlet-name>mvc-manage</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		 
		<init-param>
			<param-name>contextConfigLocation</param-name>
			<param-value>classpath:spring/mvc-servlet.xml</param-value>
		</init-param>
		<load-on-startup>1</load-on-startup>
	</servlet>

2 相關:spring3.x企業應用3.4.2節 啟動webapplicationcontext有兩種方式:conrextloaderservlet和contextLoaderListener(contextConfigLocation)

4 更多細節還是看spring技術內幕書吧