我想通过URL参数更改配置,并尝试如下。GString错误 - 如何在程序[Grails]中使用URL参数
在控制器Config.groovy中
class TestController {
def grailsApplication
def changeConfig{
Map testConfig = grailsApplication.config.test
def accountConfig = testConfig.${params.account}
}
}
test {
'default' {
debug = false
Key = 'aaa'
}
'another' {
debug = true
Key = 'bbb'
}
}
然后,我想通过改变配置运行网址,如下所示
http://localhost/myApp/test/changeConfig?account=another
但是,此代码像下面的错误。
Class groovy.lang.MissingMethodException
Message No signature of method: groovy.util.ConfigObject.$() is applicable for argument types:
如何通过URL参数更改配置?
你需要把$ {}双引号内 “” 在常规类。 – Ramsharan 2015-04-05 12:03:16
我明白了,谢谢。 – SpaceNet 2015-05-06 11:46:52