struts2默认是读取classes目录下的配置文件,要更改配置文件目录,需在web.xml的filter中加入config的参数,来配置struts.xml的路径
我是把struts.xml放到了WEB-INF/config/struts/中了,然后struts.xml又include了一些模块的配置,目录如下
项目的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"/>
最后
以上就是典雅便当最近收集整理的关于struts2更改配置文件目录的全部内容,更多相关struts2更改配置文件目录内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复