Tuesday, January 12, 2010

Get MIME types to work in Grails

A powerful aspect of Grails is that you can instruct the server to return data in any number of formats declaratively. For example, when implementing AJAX, you might choose to return XML or JSON to the JavaScript callback function.

This would work fine except Grails, by default, disables this feature, always returning HTML. To fix this, edit: grails-app/conf/Config.groovy and change the "grails.mime.use.accept.header" value to "true".

No comments:

Post a Comment