I have a situation. I want to set one value to some parameter in Config.groovy in my Grails project. This parameter should have different value for each environment, i.e. for dev environment it is like abc = "devValue", for test environment like abc="testValue" and for production environment like abc="prodValue". and then I want to set that value as a hidden field value on gsp page according to running environment.
how to set value in Config.groovy and get different value for same parameter according to environment on gsp in Grails?
459 Views Asked by Jigar Patel At
2
There are 2 best solutions below
0

Thanks Igor Artamonov,
I found the solution below.
I added code below in Config.groovy
environments {
development {
abc="devValue"
}
test {
abc="testValue"
}
production {
abc="prodValue"
}
}
And then in gsp i set the hidden field as below.
<input id="oid" type="hidden" name="oid" value="${grailsApplication.config.abc}">
Thank you.
There's already an example of this in the
Config.groovy
that's generated for you:so you can just add your setting there: