当我们想把struts.xml放在非src目录下时,需要在web.xml文件中配置struts2过滤器注入值config,比如把配置文件放在com.luo.config包下,配置如下
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>struts-default.xml,struts-plugin.xml,com/luo/config/struts.xml</param-value>
</init-param>
</filter>
不知道为什么在自己的配置文件路径前加classpath 会找不到该文件
本文详细介绍了如何将Struts2的struts.xml配置文件放置在非src目录下,并通过web.xml中的Struts2过滤器进行配置。具体展示了如何指定自定义配置文件的位置,包括使用相对路径的方法。

983

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



