SpringMVC子父容器源码剖析
一、子父容器启动流程

二、环境准备
-
在spring源码中创建一个新的module

-
build.gradle
plugins { id 'java' id 'war' } group 'com.dabing.springmvc' version '5.1.13.BUILD-SNAPSHOT' sourceCompatibility = 11 repositories { mavenCentral() } dependencies { compile(project(":spring-webmvc")) compile(project(":spring-tx")) compile(project(":spring-jdbc")) testCompile group: 'junit', name: 'junit', version: '4.12' } -
web.xml (DispatcherServlet配置的请求时进行加载创建)
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd" > <web-app> <display-name>Archetype Created Web Application</display-name> <!--spring容器配置--> <!--1. 配置全局初始化参数,让服务器启动加载spring的配置文件--> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!--2. Spring监听器,监听服务器的启动(在服务器启动的时候,创建spring容器)--> <listener> <listener-class>org.springframework.web.context.Conte

本文深入剖析SpringMVC和SpringIOC容器的启动流程,通过web.xml配置展示了Spring框架的环境搭建。在服务器启动时,ContextLoaderListener创建父容器,DispatcherServlet请求时初始化SpringMVC子容器,并设置父容器引用。文章详细解读了从父容器到子容器的初始化过程,阐述了两者之间的bean访问权限特点。
最低0.47元/天 解锁文章
1178

被折叠的 条评论
为什么被折叠?



