研究了很多办法,找了很多资料都不能实现使用通配符配置多个文件,最后发展只有把配置文件放在/WEB-INF/classes/目录下面才能使用通配符配置多个文件:
1.首先我们可以吧struts.xml放入任意位置。
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<include file="com/struts/config/struts_*.xml"></include>
</struts>
2.把web.xml中配置sturts.xml的位置
<filter>
<!-- 定义核心Filter的名字 -->
<filter-name>struts2</filter-name>
<!-- 定义核心Filter的实现类 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<param-value>
struts-default.xml,
struts-plugin.xml,
com/struts/config/struts.xml
</param-value>
</init-param>
</filter>