在自定义错误页面中获取错误的详细信息

时间:2010-03-17 11:14:58

标签: grails

我实现了一个处理HTTP错误代码的控制器:

class ErrorController {

    // 500
    def internalserver = {

    }

    // 504
    def timeout = {

    }

    // 404
    def notfound = {
        // just testing the values
        log.debug "params: ${params}"
        log.debug "response: ${response}"
        log.debug "url: ${response.redirectURL}"
        log.debug "object: ${response.content}"
    }

    // 403
    def forbidden = {

    }
}

请注意,我已经更新了UrlMappings。

"500"(controller:'error', action:'internalserver')
"504"(controller:'error', action:'timeout')
"404"(controller:'error', action:'notfound')
"403"(controller:'error', action:'forbidden')

有没有办法检索每个动作中的细节?

即。对于404,请求的URL。 500,异常消息或其他什么。

1 个答案:

答案 0 :(得分:0)

看起来只是简单地提到:

  

的grails-app /视图/ error.gsp

将显示所有需要的信息。