我有一个问题,不知道该如何解决。
我在控制器的操作方法中进行测试,如果测试结果为正,我想要重定向。
public function contentAction() {
$response = $this->render('MyBundle:Default:content.html.twig');
if(!is_object($agent)) {
$response = $this->redirect($this->get('router')->generate('new_route',
array('error_message_key' => $error_message)));
}
return $response;
}
重定向后,我遇到了异常
Error when rendering "http://alternativefirst/app_dev.php/accueil/" (Status code is 302)
我无法进行重定向,可能是什么原因?
重要提示:我在twig模板中调用了这个控制器动作。
{{ render(controller('MyBundle:Default:content')) }}
$this->render(MyBundle:Default:content.html.twig');
缺少在MyBundle
前的引号。 - sjagr