How to access Grails configuration?

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.

Leave a Reply

Your email address will not be published. Required fields are marked *


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>