views:

292

answers:

2

Hi, I'm writing Grails application, that sometimes responds with 422 http status code (on invalid AJAX calls). While deployed on Glassfish, container includes default error page after my view's rendered text.

How to change this behaviour?

Regards, Tarmo

A: 

Adding an <error-page> element in your web.xml should work:

<error-page>
  <error-code>422</error-code>
  <location>location_of_your_custom_error_page</location>
</error-page> 

To do so, run:

grails install-templates

Edit

src/templates/artifacts/war/web.xml 
Pascal Thivent
A: 

From within your Grails application you can configure the error code mappings by creating a Response Code URL Mapping in grails-app/conf/UrlMappings.groovy. This URL mapping can let you map a status code to an error page specific to that code.

class UrlMappings {
    static mappings = {
        "422"(controller:"errors", action:"my422Error")
        ...
    }
}
Colin Harrington