1.struts2框架将自动加载放在WEB-INF/classes路径下的struts.xml文件
或者使用config参数来配置
2.Spring提供一个ContextLoaderListener类,该类作为Web应用的Listener使用,会在Web应用启动时咨询偶那个查找WEB-INF/下的applicationContext.ximl配置文件,或者使用contextConfigLocation参数来配置
或者使用config参数来配置
<filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>
struts-default.xml, ../conf/struts.xml
</param-value>
</init-param>
</filter>
2.Spring提供一个ContextLoaderListener类,该类作为Web应用的Listener使用,会在Web应用启动时咨询偶那个查找WEB-INF/下的applicationContext.ximl配置文件,或者使用contextConfigLocation参数来配置
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
本文介绍了Struts2框架如何自动加载配置文件以及Spring通过ContextLoaderListener类在Web应用启动时加载配置文件的方法。
731

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



