zl程序教程

您现在的位置是:首页 >  后端

当前栏目

SpringMVC XXX-servlet.xml ApplicationContext.xml

SpringMVCXMLServlet xxx ApplicationContext
2023-09-27 14:23:13 时间

因为直接使用了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了。