ApplicationContext获取

男儿欲遂平生志,六经勤向窗前读。这篇文章主要讲述ApplicationContext获取相关的知识,希望能为你提供帮助。
spring有2个容器,一个放controller(位于child),一个放组件(位于parent)
 

child WebApplicationContext webApp=RequestContextUtils.getWebApplicationContext(request    , request.getSession().getServletContext());    
parent ApplicationContext ac1 = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getSession().getServletContext());  
parent ApplicationContext ac2 = WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());  
parent WebApplicationContext webApplicationContext = (WebApplicationContext) request.getSession().getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);  
parent WebApplicationContext cc = ContextLoader.getCurrentWebApplicationContext()
【ApplicationContext获取】 

    推荐阅读