Zend框架中重定向和转发有什么区别?
什么时候应该使用重定向,什么时候应该使用前进?
我想知道它是否可以使用flash messenger而无需重定向?例如.登录失败后,我想继续显示表单,不需要重定向.
public function loginAction() {
$form = new Application_Form_Login();
...
if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
$authAdapter = new Application_Auth_Adapter($form->getValue('username'), $form->getValue('password'));
if ($this->auth->authenticate($authAdapter)->isValid()) {
...
} else {
// login failed
$this->flashMessenger->addMessage('Login failed. You may have entered an invalid username and/or password. Try again');
}
}
$this->view->form = $form;
}
Run Code Online (Sandbox Code Playgroud)