dispatch-servlet.xml与applicationContext.xml

spring的配置文件:applicationContext.xml定义的是“root webapp context”,直译过来就是根应用上下文。(通常配置bean、数据库链接、事务、shiro、开启任务task配置等等)web

springmvc的配置文件:dispatcher-servlet.xml定义一个servlet的应用上下文,是applicationContext.xml上下文的子类。(通常配置视图解析器、扫描指定的包中的类上的注解、添加静态资源访问的支持等等)spring

在初始化时,applicationContext.xml首先初始化,而dispatcher-servlet.xml在对应的servlet实例化时启动,所以applicationContext.xml初始化在前,而dispatcher-servlet.xml初始化在后。数据库

dispatcher-servlet.xml中的bean能够引用父类applicationContext.xml上下文中的bean,反之不能够mvc

相关文章
相关标签/搜索