Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 544
Topera Avatar asked Apr 27 '11 14:04

Topera


1 Answers

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

like image 175
Victor Sergienko Avatar answered Oct 04 '22 17:10

Victor Sergienko