作者:++
ContextLoder 加载WEB.XML里的contextConfigLocation字段
如下:
<web-app>
<display-name>bbscs6</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
</web-app>
把/WEB-INF/applicationContext.xml加载入ApplicationContext
并用servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, ApplicationContext);加载到容器
用 ApplicationContext wac = WebApplicationContextUtils.getRequiredWebApplicationContext(ServletContext);来取出ApplicationContext
ApplicationContext通过getBean("xxxx")来取到相应的bean