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

 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文件键值}

猜你喜欢

转载自wuhen639.iteye.com/blog/2248931