我在控制器中,我想重定向回URL,比如/ home/news/example#comment1423
如何将哈希值添加到返回参数中?
return $this->redirect(
    $this->generateUrl("news_view", array("permalink" => "example"))
);
Run Code Online (Sandbox Code Playgroud)
    gil*_*den 28
最简单的解决方案可能是连接:
$url = $this->generateUrl("news_view", array("permalink" => "example"));
return $this->redirect(
    sprintf('%s#%s', $url, 'comment1423')
);
Run Code Online (Sandbox Code Playgroud)
        在 Symfony 3.2 中,你可以这样做:
// generating a URL with a fragment (/settings#password)
$this->redirectToRoute('user_settings', ['_fragment' => 'password']);
Run Code Online (Sandbox Code Playgroud)
请参阅https://symfony.com/blog/new-in-symfony-3-2-routing-improvements
|   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           30028 次  |  
        
|   最近记录:  |