我在 Controller 中,我想重定向回某个 URL,例如/home/news/example#comment1423
如何将哈希值添加到返回参数中?
return $this->redirect(
$this->generateUrl("news_view", array("permalink" => "example"))
);
最佳答案
最简单的解决方案可能是串联:
$url = $this->generateUrl("news_view", array("permalink" => "example"));
return $this->redirect(
sprintf('%s#%s', $url, 'comment1423')
);
关于symfony - 在 Symfony2 中,如何在 Controller 内重定向到带有 anchor 标记/哈希的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7724082/