为什么我不能在Symfony 1.4中使用两个参数进行重定向?
$this->redirect('news/edit?id='.$news->getId() . '&test='.$news->getTest());
这会将我重定向到 http://mysite.com/news/edit/id/3 而不是:
http://mysite.com/news/edit/id/3/test/4
如何使用两个参数进行重定向?
您的解决方案应该可以正常工作。
但是检查$news->getTest()
是否不为空,并检查您是否没有出现问题的路由。
或者,您可以尝试一下:
$this->getRequest()->setParameter('id', $news->getId());
$this->getRequest()->setParameter('test', $news->getTest());
$this->forward('news', 'edit');
重定向 expecst 一个 URL,您可以使用 URL 帮助程序方法构建此 URL,例如
url_for2($routeName, $params = array());
其中参数是一个关联数组。