zoukankan      html  css  js  c++  java
  • Struts2更改配置文件struts.xml默认路径

    struts2配置文件默认存放路径在/WEB-INF/classes目录下,即将struts.xml放在src的目录下。

    但是为了协作开发与方便管理,我们有时需要把struts.xml放到其他位置

    struts2加载配置文件都是先从自己的jar包和/WEB-INF/classes两个默认的位置加载的。

    若修改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,com/home/conf/struts-category.xml</param-value>
    	</init-param>
    </filter>
    因为设置了<param-name>config</param-name>参数,所以struts-default.xml,struts-plugin.xml等原来

    struts2默认加载的文件也需要手动指定,否则不会自动加载。

    上面com/home/conf/struts-category.xml采用相对路径即我们需要改变路径的文件,

    本例放在了/WEB-INF/classes/com/home/conf/目录下

    若不在这里配置struts-default.xml,struts-plugin.xml,也可在struts.xml文件中include将两个文件包含进来。

    <include file="struts-default.xml" />
    <include file="struts-plugin.xml" />


    如若约定大于配置,多个子配置文件的话可以采用扫描的方式如:

    <include file="com/home/conf/struts-*.xml" />
    或直接
    <include file="com/home/conf/*.xml" />


    作者:itmyhome

     出处: http://blog.csdn.net/itmyhome1990/article/details/39344263



  • 相关阅读:
    求某个数的位数公式
    ArrayList和lInkedList比较
    队列
    抽象数据结构-栈
    LinkedList的实现
    ArrayList的实现
    Iterator和List的一些问题
    SCHEMA约束
    DTD约束
    XML解析
  • 原文地址:https://www.cnblogs.com/itmyhome/p/4131248.html
Copyright © 2011-2022 走看看