2

我在控制器中有一个看起来像这样的函数

void function edit(required struct rc) output="false"   {

   ...

   if (...) {

      ArrayAppend(rc.message, "<b>Error:</b> Something did not work right.");

      variables.fw.redirect(".home", "all");
      return;  // ?
      } 

   }

我需要return还是重定向是否意味着返回?

4

1 回答 1

6

如果您查看 FW/1 源代码中的重定向方法,您会发现它只是执行常规 cflocation。这意味着,页面执行不会超过那行代码,因此返回应该是不必要的。

https://github.com/framework-one/fw1/blob/develop/framework/one.cfc#L1031

代码片段

 ...
 location( targetURL, false, statusCode );
 ...
于 2014-11-19T22:44:54.237 回答