【发布时间】:2014-04-10 06:52:58
【问题描述】:
在 URL 映射文件中,我已将 404 错误与 ErrorController 的 notFound 操作联系起来。
class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"500"(controller: "errorPage", action: "internalError")
"403"(controller: "errorPage", action: "forbidden")
"404"(controller: "errorPage", action: "notFound")
}
如果任何控制器不进行渲染调用并且该操作不存在默认视图,它会调用 ErrorPageController 的 notFound 操作。现在,我想知道在这个 notFound 操作中调用了哪个操作,因为调用了 404 异常。怎么可能知道?例如,在 500 的情况下,internalError 操作获取 request.exception,通过它我们知道调用 internalError 发生了什么。 404错误也需要做同样的事情。
【问题讨论】:
标签: grails