applicationContext.xml文件中怎么配置struts2和spring配置文件的加载路径

来源:互联网 发布:淘宝宝贝如何上下架 编辑:程序博客网 时间:2024/06/06 00:10

场景:要求项目的spring配置文件存在 src/springCfg  目录下,struts2的配置文件存放在 src/strutsCfg  目录下

 

为了实现该场景,在appltionContext.xml文件中的配置如下:

    <!--Spring配置-->    <context-param>        <param-name>contextConfigLocation</param-name>        <param-value>classpath*:springCfg/spring-*.xml</param-value>    </context-param>    <listener>        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>    </listener>    <!-- struts2配置 -->    <filter>        <filter-name>struts2</filter-name>        <filter-class>            support.struts2.filter.CustomStrutsPrepareAndExecuteFilter        </filter-class>        <init-param>            <param-name>configPattern</param-name>            <param-value>classpath*:strutsCfg/struts-*.xml</param-value>        </init-param>        <init-param>            <param-name>configProviders</param-name>            <param-value>support.struts2.config.providers.CustomConfigurationProvider</param-value>        </init-param>    </filter>


 

注意:通过该方式也可以只加载特定的某个文件作为配置文件

 

阅读全文
0 0
原创粉丝点击