您好我从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');
}
身份验证网址为http://localhost/customer/authenticate,这似乎工作正常,但不会重定向。在身份验证后,我得到一个空白页面,看起来像是把它带到了索引并且只是坐在那里。我尝试使用'/ index'代替,但这也没有帮助。我是否需要做一些特殊的事情来使重定向器助手工作?我的退出操作行为相同。
答案 0 :(得分:0)
你应该致电
$this->_helper->redirector('index');
没有 返回。
答案 1 :(得分:0)
我发现我的设置可能有问题。上面的代码很完美,适用于另一台计算机。