我想从grails控制器传递错误消息到grails错误控制器,以便在HTTP响应中显示错误消息,但我不确定哪些参数在错误控制器中保存了错误消息。如何在Grails控制器之间传递错误消息?
URLMappings.groovy
所有500错误都映射到ErrorsController
"500"(controller: "errors", action: "serverError")
GenericController
def {
try{
//do some work
}catch(Exception e){
response.sendError(500, e.getMessage())
}
}
ErrorsController
def serverError = {
render(how can I access the exception details here??)
}
我需要访问ErrorsController中的异常,以便我可以将它输出到HTTP响应中。
甜,工作很好,thx – raffian
我注意到'flash.message'有时会显示两次;首先用于初始请求,再用于下一个请求;为了解决这个问题,我使用'request.message'来代替这个问题:闪存信息有什么意义? – raffian