我想通過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