简体   繁体   中英

The difference between render(…) and g.render(…) in grails

I have the following bit in a controller:

            def myJSON = [

                    'form' : g.render(template: '/information/form', model:informationInstance)
            ]

            render myJSON as JSON

... and wonder what's the difference between and purpose of render() and g.render() ?? And where does ' g ' come from?

The g is the namespace for the Grails tag library. It is automatically injected into controllers and views. In a controller, you access it as g.XXX() rather than <g:XXX /> . There really is no difference in how they function under the covers except with how the controller triggers its response.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM