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()

 

posted @ 2018-03-08 11:00  baliure  阅读(116)  评论(0编辑  收藏  举报