从.properties文件读取参数到.xml文件

我有一个application.xml文件(directory = WEB-INF / application.xml)

我有一个jasperserver.properties文件(directory = WEB-INF / internal / jasperserver.properties)

这是在jasperserver.properties文件

SERVICE_URL=http://b-reptest-lnx.nwu.ac.za:8026/jasperserver-pro/j_spring_cas_security

我想从application.xml文件中读取“SERVICE_URL”属性

我该怎么做呢 ?

解决方法

在application.xml中使用PropertyPlaceholderConfigurer.

<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  <property name="location">
    <value>classpath:path/to/jasperserver.properties</value>
  </property>
</bean>

加载属性文件.
然后在application.xml中使用${SERVICE_URL}来替换值:

<bean class="your class">
  <property name="serviceURL"><value>${SERVICE_URL}</value></property>
</bean>

相关文章

php输出xml格式字符串
J2ME Mobile 3D入门教程系列文章之一
XML轻松学习手册
XML入门的常见问题(一)
XML入门的常见问题(三)
XML轻松学习手册(2)XML概念