I\'m having some problems getting Grails to map my 404 errors to an errors controller like in the documentation. I\'m running Grails 1.3.5 and when I add the following mappi
Add the following code to your application's scripts/Events.groovy:
import groovy.xml.StreamingMarkupBuilder
//modify the generated web.xml so that it supports being mapped to 'error'
eventWebXmlEnd = {String tmpfile ->
//find the filter mapping to change
String filterNm = "grailsWebRequest"
def root = new XmlSlurper().parse(webXmlFile)
def gwr = root."filter-mapping".find { it."filter-name" == filterNm }
if (!gwr.size()) throw new RuntimeException(
"[fail] No Filter named $filterNm")
// xml is as expected, now modify it and write it back out
gwr.appendNode {
dispatcher("ERROR")
}
// webXmlFile is an implicit variable created before event is invoked
webXmlFile.text = new StreamingMarkupBuilder().bind {
mkp.declareNamespace("": "http://java.sun.com/xml/ns/j2ee")
mkp.yield(root)
}
}
See this post for an explanation. Note that I've copied the above script from that posting, but it had to be amended as the web.xml's structure appears to have changed since the time of the posting's writing.
http://jira.codehaus.org/browse/GRAILS-4232 I think this is a known issue
after deleting whitespace, the problem solved
"404"(controller:'errors', action:'notFound')