使用属性文件中的属性 [英] using properties within the properties file
问题描述
我为标题道歉..我找不到更好的方法来解释这种情况。
I apologize for the title.. i couldn't find a better way to explain the situation.
我使用Property类加载属性文件,如上所述在网址 http://www.exampledepot.com/egs/java.util/ Props.html
I use to load properties file using a Property class as described in the URL http://www.exampledepot.com/egs/java.util/Props.html
我的问题是我可以使用该属性文件中的属性吗?
my question is can I use properties within that properties file ?
示例:
test.properties
test.properties
url.main="http://mysite.com"
url.games={url.main}/games
url.images={url.main}/images
.
.
.
是否可以使用其他语法?
is that possible with some other syntax?
谢谢
推荐答案
之前从未见过。您可以制作您自己的预处理器。只要引用的属性在对它的任何引用之前发生,您应该能够使用一些正则表达式/字符串替换来实现它。但是:我不会推荐这种方法。
Never seen that before. You could make your own preprocessor of course. As long as the referenced property occurs before any references to it, you should be able to implement it using some regular expressions/string replacement. But: I would not recommend this method.
通过定义不同的属性更好地解决重复问题:
Better resolve the duplication by defining different properties:
- 将
url.games = {url.main} / games
更改为url.games_extension = /游戏
- prepend:
url.main
到url.games_extension
在您的应用程序代码中获取完整的游戏URL。
- change:
url.games={url.main}/games
intourl.games_extension=/games
- prepend:
url.main
tourl.games_extension
to get the full games url in your application code.
这篇关于使用属性文件中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!