Search code examples
grailshttp-redirectforward

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


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?


Solution

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