"404" (controller: 'error', action: 'pageNotFound')
Any changes to response.status inside the pageNotFound action is reverted back to 404 before the response is sent to the client. Is it possible to work around this开发者_JAVA技巧 some way? I would like to be able to change it to 410 when I detect that the resource has been deleted or 301 when it's moved permanently.
If that's not working try this in your error controller:
class ErrorController {
def notFound = {
redirect( action: 'gone')
}
def gone= {
response.sendError(410, "Gone")
}
}
Try setting the header yourself manually by response.setHeader()
精彩评论