2012-12-10 19 views
1

我在一個位置有一個屬性文件(/ home/XXXX),並希望它的某個屬性在位置(/ irb/dev4/ccm_wa/cb532/RBAPI-XXX/RBAPI/BA/tools/src/COM/GEN /工具/建設/ J2EE/EJB)。我們如何訪問它們?如何訪問速度Templete的屬性?

我只需要如果上面的訪問屬性返回true

#if(**PROPERTY IS TRUE**) 
#foreach ($databaseGroup in ${root.getAllDatabaseGroups().values()}) 
#foreach ($index in ${databaseGroup.getIndices()}) 
     <resource-ref> 
     <res-ref-name>${databaseGroup.getResRefPrefix()}${databaseGroup.getTxDs(${index})}</res-ref-name> 
     <resource-name>${databaseGroup.getResRefPrefix()}${databaseGroup.getTxDs(${index})}</resource-name> 
     </resource-ref> 

回答

0

在你的模板類讀取屬性文件爲Properties對象,並把這個上下文中執行下面的foreach循環。我建議爲Apache Commons PropertiesyConfiguration

PropertiesConfiguration props = new PropertiesConfiguration("/home/XXXX"); 
contxt.put("props", props); 

在模板文件中您現在可以檢查您的屬性:

#if($props.getBoolean(propertyName))