SpringMVC XXX-servlet.xml ApplicationContext.xml

因为直接使用了SpringMVC,所以之前一直不明白xxx-servlet.xmlapplicationContext.xml是如何区别的,其实如果直接使用SpringMVC是可以不添加applicationContext.xml文件的。
使用applicationContext.xml文件时是需要在web.xml中添加listener的:
<listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
而这个一般是采用非spring mvc架构,如使用struts之类而又想引入spring才添加的,这个是用来加载Application Context。
如果直接采用SpringMVC,只需要把所有相关配置放到xxx-servlet.xml中就OK了。

posted @ 2014-12-30 18:08  Lost blog  阅读(249)  评论(0编辑  收藏  举报