Unable to create a 404 page in Grails
My mappings look like
static mappings = {
"/" (controller : "welcome", action : "index")
"/about" (controller : "welcome", action : "about")
"404" (controller : "welcome", action : "notFound")
}
This doesn't seem to catch 404 requests as I still get the default Tomcat 404 page. I have also tried the closure based method (below) with no success.
"404" {
controller = "welcome"
action = "notFound"
}
Versions:
versions: {
app.version: "0.1"
app.servlet.version: "2.4"
app.grails.version: "1.3.5"
plugins.tomcat开发者_StackOverflow中文版: "1.3.5"
plugins.hibernate: "1.3.5"
}
I have succeeded by removing whitespace on the 404 line:
"404"(controller : "welcome", action : "notFound")
What version of Grails are you running?
Also, what does your controller action look like? This person seems to have resolved the issue by using a redirect in their controller instead of a render:
Problems with Grails 404 UrlMapping
def notFound = {
redirect(uri:"/404.html")
}
精彩评论