简体   繁体   English

为什么 grails 中的转发和重定向不会停止初始操作执行?

[英]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".我在 Grails 中阅读了有关转发重定向的信息,但不明白为什么下面的代码会打印“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?这是一个错误还是我理解错误的概念?

Because these are just function calls - they can't exit from a calling function (your action).因为这些 只是 function 调用- 它们不能从调用 function (您的操作)中退出。 Just put return afterwards.只是把return之后。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM