To render different forms of responses from simple text responses, to view and templates.


// renders text to response
render "some text"

// renders text for a specified content-type/encoding render(text:"<xml>some xml</xml>",contentType:"text/xml",encoding:"UTF-8")

// render a template to the response for the specified model render(template:"book",model:[book:new Book(title:'The Shining',author:'Stephen King')])

// render each item in the collection using the specified template render(template:"book",collection:[b1, b2, b3])

// render a template to the response for the specified bean render(template:"book",bean:new Book(title:'The Shining',author:'Stephen King'))

// render the view with the specified model render(view:"viewName",model:[book:new Book(author:'Stephen King')])

// render the view with the controller as the model render(view:"viewName")

// render some markup to the response render { div(id:"myDiv", "some text inside the div") }

// render some XML markup to the response render(contentType:"text/xml") { books { for(b in books) { book(title:b.title, } } }

// render a JSON ( ) response with the builder attribute: render(contentType:"text/json") { book(title:b.title,


// render with status code render(status: 503, text: 'Failed to update book ${}')

// Automatic marshalling of XML and JSON import grails.converters.* … render Book.list(params) as JSON render Book.get( as XML


A multi-purpose method for rendering responses to the client which is best illustrated with a few examples! Warning, as of Grails 0.5, this method does not always support multiple parameters. For example, if you specify both collection and model, the model parameter will be ignored. Parameters