【IT168技术文档】
进入contextLoaderListener看看到底加载时做了甚么
==>org.springframework.web.context.ContextLoaderListener
public class ContextLoaderListener implements ServletContextListener ...{
![]()
private ContextLoader contextLoader;
![]()
/**//**
* Initialize the root web application context.
*/
//当WEB上下文初始化时,系统会调用此方法
public void contextInitialized(ServletContextEvent event) ...{
this.contextLoader = createContextLoader();
![]()
<span style="color:red;">
//监听到WEB上下文初始化的时候执行SPRING上下文contextLoader的初始化工作
this.contextLoader.initWebApplicationContext(event.getServletContext());
</span>
}
![]()
/**//**
* Create the ContextLoader to use. Can be overridden in subclasses.
* @return the new ContextLoader
*/
protected ContextLoader createContextLoader() ...{
return new ContextLoader();
}
![]()
/**//**
* Return the ContextLoader used by this listener.
*/
public ContextLoader getContextLoader() ...{
return contextLoader;
}
![]()
/**//**
* Close the root web application context.
*/
public void contextDestroyed(ServletContextEvent event) ...{
if (this.contextLoader != null) ...{
this.contextLoader.closeWebApplicationContext(event.getServletContext());
}
}
![]()
}
