我实现了一个处理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,异常消息或其他什么。
答案 0 :(得分:0)
看起来只是简单地提到:
的grails-app /视图/ error.gsp
将显示所有需要的信息。