ApplicationContext.xml 是spring 全局配置文件,用来控制spring 特性的、比如:aop,sessionFactory
xxx-servlet.xml 是spring mvc里面的,控制器、拦截uri转发view
注:
(1)如果直接使用SpringMVC是可以不添加applicationContext.xml文件的。
只需要把所有相关配置放到xxx-servlet.xml中就OK了。
(2)使用applicationContext.xml文件时是需要在web.xml中添加listener的:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
而这个一般是采用非spring mvc架构,如使用struts之类而又想引入spring才添加的,这个是用来加载Application Context。
(2)使用applicationContext.xml文件时是需要在web.xml中添加listener的:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
而这个一般是采用非spring mvc架构,如使用struts之类而又想引入spring才添加的,这个是用来加载Application Context。
本文介绍了Spring MVC架构中两种核心配置文件的作用:ApplicationContext.xml用于全局配置,支持AOP等功能;xxx-servlet.xml则专注于控制器配置及视图转发。文中还提到了在不同架构下这两种配置文件的应用方式。
792

被折叠的 条评论
为什么被折叠?



