2016-04-29 30 views
0

重定向Symfony3中的其他URL我無法如何使用參數重定向其他URL。在以下代碼中,它顯示$ resultFlg等於True時的錯誤消息。如何使用參數

消息指出'無法爲指定的路由生成URL「snsForm」,因爲這樣的路由不存在'。我不明白原因和解決辦法。請使用routing.yml作爲參考。然後,Symfony版本是3.0.4-DEV。

的src /的appbundle /控制器/ UserController.php

應用程序/配置/ routing.yml中

app: 
resource: "@AppBundle/Controller/" 
type:  annotation 

回答

1

您需要直接到路線不是URL的名稱。你的情況是「regsiterSnsRoute」

return $this->redirect($this->generateUrl('regsiterSnsRoute')); 

也可以縮短該行

return $this->redirectToRoute('regsiterSnsRoute'); 
+0

感謝您的回答,重定向功能正常工作。我以爲我必須輸入URL路徑,因爲方法名是generateUrl。 – hikozuma