0

您好,我从 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',但这也无济于事。我需要做一些特别的事情来使重定向器助手工作吗?我有一个行为相同的注销操作。

4

2 回答 2

0

你应该打电话

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

没有回报。_

于 2010-03-16T22:46:23.753 回答
0

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

于 2010-03-18T01:16:29.100 回答