使用属性文件中的属性 [英] using properties within the properties file

查看:109
本文介绍了使用属性文件中的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为标题道歉..我找不到更好的方法来解释这种情况。

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:


  1. url.games = {url.main} / games 更改为 url.games_extension = /游戏

  2. prepend: url.main url.games_extension 在您的应用程序代码中获取完整的游戏URL。

  1. change: url.games={url.main}/games into url.games_extension=/games
  2. prepend: url.main to url.games_extension to get the full games url in your application code.

这篇关于使用属性文件中的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆