Mapping to response codes doesn't work
Hi again,
according to the grails documentation I've got this in my UrlMappings.groovy:
Code:
"403"(controller: "errors", action: "forbidden")
"404"(controller: "errors", action: "notFound")
"500"(controller: "errors", action: "serverError")
In my security filter I'm redirecting like this:
Code:
redirect(controller: "errors", action: "forbidden")
However I'm always getting a 404 after the redirect. So I tried adding:
Code:
static mappings = {
"403"(view: "/errors/forbidden")
"404"(view: "/errors/notFound")
"500"(view: "/errors/serverError")
}
as the redirect points to "/errors/forbidden". However I'm getting a 404 again. In case that ordering matters in some way I added these mappings at the top of the file.
I ended up with:
response.sendError(403, "forbidden")
Which works just fine. But I'm wondering why the other way didn't work. Am I getting something totally wrong or am I just missing a small piece?
Cheers,
Thomas