tomcat容器启动加载web.xml初始化springmvc相关策略组件
一、WebApplicationContext的层次结构
本来是想研究一下springMVC组件的,结果解决了以前的一个疑问。WebApplicationContext的层次结构
下面是从官网copy的一份web.xml
ContextLoaderListener:初始化一个Root WebApplicationContext:SpringIOC初始化一些中间services+datasouces的Bean
DispatcherServlet:初始化一个Servlet WebApplicationContext:SpringIOC初始化前端controllers+view resovlers+HandleMapping的Bean
父子关系:Servlet WebApplicationContext.setParent(Root WebApplicationContext);子容器找不到就去父容器找。
org.springframework.web.context.ContextLoaderListener contextConfigLocation /WEB-INF/app-context.xml app org.springframework.web.servlet.DispatcherServlet contextConfigLocation 1 app /app protected void initStrategies(ApplicationContext context) { initMultipartResolver(context); initLocaleResolver(context); initThemeResolver(context); initHandlerMappings(context); initHandlerAdapters(context); initHandlerExceptionResolvers(context); initRequestToViewNameTranslator(context); initViewResolvers(context); initFlashMapManager(context); }
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持考高分网。



