0

嗨,我正在尝试使用重定向,redirect(uri: "/errors/handle500")但出现以下异常

Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.. Stacktrace follows:
  org.codehaus.groovy.grails.web.servlet.mvc.exceptions.CannotRedirectException: Cannot issue a redirect(..) here. A previous call to redirect(..) has already redirected the response.
  at com.cisco.rms.ErrorsController$_closure1.doCall(ErrorsController.groovy:8)
2012-10-03 18:05:53,414 [http-bio-8080-exec-7] ERROR errors.GrailsExceptionResolver  - CannotRedirectException occurred when processing request: [GET] /rmsportal/changeRequest/listJSONFromService 

谁能告诉我为什么它没有重定向。

4

2 回答 2

0

tim_yates 是对的,你不能调用第二个重定向。也许您想改用forward,并记住仅重定向并不能阻止 grails 执行其余的控制器代码。

于 2012-10-03T16:47:05.677 回答
0

这是我的错误样本。

if (checkSomething){
    redirect action: 'foo'
}
....
redirect action: 'bar'

这是正确的样本

if (checkSomething){
    redirect action: 'foo'
    return
}
....
redirect action: 'bar'
于 2016-12-03T07:04:48.830 回答