天天看點

struts2更改配置檔案目錄

struts2預設是讀取classes目錄下的配置檔案,要更改配置檔案目錄,需在web.xml的filter中加入config的參數,來配置struts.xml的路徑

我是把struts.xml放到了WEB-INF/config/struts/中了,然後struts.xml又include了一些子產品的配置,目錄如下

struts2更改配置檔案目錄

項目的web.xml的配置如下

<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,../config/struts/struts.xml</param-value>
  </init-param>
</filter>
           

struts.xml的include的寫法如下

<include file="../config/struts/module/user.xml"/>
           

繼續閱讀