struts2中struts.xml非默认路径的配置
struts2中的配置文件struts.xml,默认情况下放在src下,加载时从WEB-INF/classes/下装载。下面是 从非默认路径的配置
web.xml中struts2配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<!-- 配置装载struts.xml路径,其中struts.xml放在/src/struts/下-->
<param-value>struts-default.xml,struts/struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
web.xml中struts2配置:
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
<init-param>
<param-name>config</param-name>
<!-- 配置装载struts.xml路径,其中struts.xml放在/src/struts/下-->
<param-value>struts-default.xml,struts/struts.xml</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>