zoukankan      html  css  js  c++  java
  • web.xml中contextConfigLocation的作用(转)

    在web.xml中使用contextConfigLocation参数定义要装入的Spring配置文件。

    1. 在web.xml里配置需要加载的spring配置文件。
      如果要装入多个配置文件,在<param-value>标记中用逗号作分隔符即可。

        <context-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>classpath:spring-base.xml,classpath:spring-another.xml</param-value>
        </context-param>

    2. 在web.xml里配置Listener,本Listener会去加载第一步中指定的配置文件。

       <listener>
           <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
       </listener>

    3. 如果指定了要加载的文件,则会去加载相应的xml,而不会去加载/WEB-INF/下的applicationContext.xml。(指定加载即是第1步的配置)
      如果没有指定的话,默认会去/WEB-INF/下加载applicationContext.xml。

    4. 多个配置文件里的交叉引用可以用ref的external或bean解决

        <bean id="userService" class="domain.user.service.impl.UserServiceImpl">
            <property name="dbbean">
                 <ref bean="dbBean"/>
            </property>
        </bean>
  • 相关阅读:
    pagefile.sys
    Oracle数据库同义词
    oracle临时表
    修改Oracle并行度
    Oracle 反键索引/反向索引
    Ajax基础2
    DOM高级
    面向对象--高级
    面向对象---中级
    面向对象-初级
  • 原文地址:https://www.cnblogs.com/moxiaotao/p/9306239.html
Copyright © 2011-2022 走看看