<bean id="myPropertyConfigurer" class="com.jader.common.DecryptPropertyPlaceholderConfigurer">
<property name="locations" value="classpath:config.properties" />
<property name="fileEncoding" value="UTF-8"/>
<property name="keyLocation" value="classpath:key.key" />
</bean>
<bean id="conf" class="com.jader.common.DecryptPropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
</list>
</property>
<property name="fileEncoding" value="UTF-8"/>
<property name="keyLocation" value="classpath:key.key" />
以上面的xml文件为例:
XPath 使用路径表达式在 XML 文档中选取节点。节点是通过沿着路径或者 step 来选取的。
下面列出了最有用的路径表达式:
例如:我替换classpath:config.properties
<replace xpath="/beans/bean[@id=myPropertyConfigurer]/property[@name=locations]/@value">classpath:config_test.propertis</replace>
替换class:jdbc.properties
<replace xpath="/beans/bean[@id=conf]/property[@name=locations]/list/value">classpath:config_test.propertis</replace>
选取未知节点
XPath 通配符可用来选取未知的 XML 元素。
实例
在下面的表格中,我们列出了一些路径表达式,以及这些表达式的结果:
xpath表达式在线验证:http://www.whitebeam.org/library/guide/TechNotes/xpathtestbed.rhtm
原文地址:http://blog.csdn.net/fuyuwei2015/article/details/45897637