【问题标题】:using action helpers in Zend Framework 1.8在 Zend Framework 1.8 中使用动作助手
【发布时间】:2010-03-16 14:40:43
【问题描述】:

您好,我从 Zend Framework 开始,有一个关于动作助手的问题。我的第一个应用程序是一个简单的身份验证系统(按照书中的教程)。注册和身份验证似乎工作正常,但重定向却不行。

我有一个客户控制器,其中包括:

class CustomerController extends Zend_Controller_Action 
{

// some code here......

public function authenticateAction()
{
    $request = $this->getRequest();
    if (!$request->isPost()) {
        return $this->_helper->redirector('login');
    }

    // Validate
    $form = $this->_forms['login'];
    if (!$form->isValid($request->getPost())) {
        return $this->render('login');
    }

    if (false === $this->_authService->authenticate($form->getValues())) {
        $form->setDescription('Login failed, please try again.');
        return $this->render('login');
    }

    return $this->_helper->redirector('index');
}

身份验证 url 是 http://localhost/customer/authenticate,这似乎工作正常,但它不会重定向。身份验证后,我得到一个空白页面,看起来像是将我带到了索引处,然后就坐在那里。我尝试改用'/index',但这也无济于事。我需要做一些特别的事情来使重定向器助手工作吗?我有一个行为相同的注销操作。

【问题讨论】:

    标签: zend-framework action helper


    【解决方案1】:

    你应该打电话

     $this->_helper->redirector('index');
    

    没有返回

    【讨论】:

    • 您是否尝试过将重定向器放在方法的顶部,只是为了检查它是否有效?您是否开启了错误报告?
    【解决方案2】:

    我发现我的设置可能有问题。上面的代码很完美,可以在另一台电脑上运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-07
      • 2013-04-09
      相关资源
      最近更新 更多