如何在Config.Groovy中使用设置变量并将其连接起来

时间:2010-05-19 17:50:19

标签: string grails config

我希望稍后在Config.groovy

中重复使用vars

示例:

static.serverURL = "http://static.foo.com"
static.path = ""

bar.default.picUrl=static.serverURL+static.path+"/images/bar.png"

但这给了我一个

groovy.util.ConfigObject.plus() is applicable for argument types: (java.lang.String)

将其更改为

bar.default.picUrl=""+static.serverURL+static.path+"/images/bar.png"

给了我

[:][:]/images/bar.png
使用

bar.default.picUrl=${static.serverURL}+${static.path}+"/images/bar.png"

给了我

nullnull/images/bar.png

1 个答案:

答案 0 :(得分:1)

你有没有尝试过:

bar.default.picUrl="${static.serverURL}${static.path}"/images/bar.png