dispatch-servlet.xml与applicationContext.xml

北城以北 提交于 2019-12-05 18:20:49

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

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

在初始化时,applicationContext.xml首先初始化,而dispatcher-servlet.xml在对应的servlet实例化时启动,因此applicationContext.xml初始化在前,而dispatcher-servlet.xml初始化在后。

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!