You can access grails configuration in following ways:
1. In Controller :
class DemoController {
def grailsApplication
def demoAction = {
def obj = grailsApplication.config.propertyInConfig
}
}
2. In services :
class DemoService {
def grailsApplication
def demoMethod = {
def obj = grailsApplication.config.propertyInConfig
}
}
3. In taglib :
class DemoTaglib {
def grailsApplication
static namespace = “cd”
def demoMethod = {
def obj = grailsApplication.config.propertyInConfig
out << obj
}
}
You can call this method of taglib in view as <cd:demoMethod/>
4. In view :
<html>
<head><title>Demo</title></head>
<body>
${grailsApplication.config.propertyInConfig}
</body>
</html>
ProsperaSoft offers Grails development solutions. You can email at info@prosperasoft.com to get in touch with ProsperaSoft Grails experts and consultants.