2014-01-20 123 views
0

我有性质serverpath.properties文件,XML文件名为search-servlet.xml的 有位置就像是/properties/serverpath.properties和/src/spring/search-servlet.xml访问属性文件密钥

serverpath.properties包含以下键值对 wmcorelib.authentication.url = http://qae.ws.wiley.com:8001/als

现在我想用这个键wmcorelib.authentication.url我的XML中。

任何帮助都会很大

+0

你想在运行时或编译时使用它吗? – radimpe

+0

我想要编译时间 – user2959826

+0

您可以将属性加载到hashmap中,解析XML,然后迭代其节点。如果您发现与您的地图匹配,请将值替换为键值。这种后处理适合你吗? –

回答

0

是search-servlet的一个bean定义文件吗?如果是这样的话,您可以使用spring place-holder标签来读取适当的文件,并用search-servlet中的键替换属性文件中的值。 http://docs.spring.io/spring/docs/1.1.4/api/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.html

+0

是的,它是一个bean定义文件。我使用了'place-holder'标签。 但它呈现像/classpath:/properties/myfile.properties。 在classpath之前多余的'/'正在创建错误 – user2959826