Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top