in Config.groovy I see this:
// set per-environment serverURL stem for creating absolute links
environments {
production {
grails.serverURL = "http://www.changeme.com"
}
}
what is the correct way to access that at runtime?
From stackoverflow
danb
-
here it is:
import org.codehaus.groovy.grails.commons.ConfigurationHolder println ConfigurationHolder.config.grails.serverURLalternatively, in controllers and tags, apparently this will work:
grailsApplication.config.grails.serverURLI needed it in BootStrap, so option 1 was what I needed.
From danb -
danb is on the right track. However, life gets a bit easier on your fingers if you do a nicer import:
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH println CH.config.grails.serverURLdanb : very nice.. i was completely unaware of that feature, which I will call import aliasing.From Robert Fischer
0 comments:
Post a Comment