spring context的层次关系

一、ServletContext

Defines a set of methods that a servlet uses to communicate with its servlet container, for example, to get the MIME type of a file, dispatch requests, or write to a log file.

全局的context,包含springcontext、dispatchservlet、filter、lisener等;

在tomcat扫描应用时创建。

二、spring context

WebApplicationContext

包含spring中配置的运行所需的所有全局环境变量。

contextLoaderListener时创建。

三、dispatch context

包含处理事务所需的环境变量。

被dispatcherservlet所持有,引用spring context以查找全局的环境变量。

applicationContext AnnotationConfigServletWebServerApplicationContext  (id=95)

FrameworkServlet

@Override

public void setApplicationContext(ApplicationContext applicationContext) {

if (this.webApplicationContext == null && applicationContext instanceof WebApplicationContext) {

this.webApplicationContext = (WebApplicationContext) applicationContext;

this.webApplicationContextInjected = true;

}

}

猜你喜欢

转载自www.cnblogs.com/feng9exe/p/12124996.html
今日推荐