(转) spring配置文件(xml)读取properties文件属性值

来源:互联网 发布:外墙保温锚栓拉拔数据 编辑:程序博客网 时间:2024/05/29 14:58

spring配置文件(xml)读取properties文件属性值


来源:http://vvovv.iteye.com/blog/1416667


web.xml 

<context-param> 
    <param-name>contextConfigLocation</param-name> 
    <param-value> 
        /WEB-INF/configuration/spring/applicationContext*.xml, 
    </param-value> 
</context-param> 

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


applicationContext*.xml添加 
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> 
    <property name="locations"> 
        <list> 
            <value>/WEB-INF/configuration/spring/*.properties</value> 
</list> 
    </property> 
</bean>
 
在需要使用properties属性值的地方引用${properties文件键值}
0 0
原创粉丝点击