Why forward and redirect in grails don't stop initial action execution?

蹲街弑〆低调 提交于 2019-11-30 05:47:59

问题


I read about forward and redirect in Grails and don't understant why the code bellow prints "foo".

See:

def bar = {
   redirect (controller: "public", action: "index") // same happens with forward
   println "foo" // prints this in console?? WHY?
}

In my opinion redirect/forward must skip current method execution...

Is this a bug or I understand the concept wrong?


回答1:


Because these are just function calls - they can't exit from a calling function (your action). Just put return afterwards.



来源:https://stackoverflow.com/questions/5805535/why-forward-and-redirect-in-grails-dont-stop-initial-action-execution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!