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?
Victor Sergienko
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