【IT168技术文档】
==>contextLoader.createWebApplicationContext(servletContext, parent);
protected WebApplicationContext createWebApplicationContext(
ServletContext servletContext, ApplicationContext parent) throws BeansException ...{
<span style="color:red;">
//根据servletContext来决定要实例化的WebApplicationContext
Class contextClass = determineContextClass(servletContext);
if (!ConfigurableWebApplicationContext.class.isAssignableFrom(contextClass)) ...{
throw new ApplicationContextException("Custom context class [" + contextClass.getName() +
"] is not of type ConfigurableWebApplicationContext");
}
ConfigurableWebApplicationContext wac =
(ConfigurableWebApplicationContext) BeanUtils.instantiateClass(contextClass);
wac.setParent(parent);
wac.setServletContext(servletContext);
![]()
//得到WEB.XML中设置的SPRING配置文件位置
String configLocation = servletContext.getInitParameter(CONFIG_LOCATION_PARAM);
if (configLocation != null) ...{
//把配置文件分段后设置到WebApplicationContext的ConfigLocations中
wac.setConfigLocations(StringUtils.tokenizeToStringArray(configLocation,
ConfigurableWebApplicationContext.CONFIG_LOCATION_DELIMITERS));
}
//刷新WebApplicationContext
wac.refresh();
</span>
return wac;
}
