[英]Redirect to "/" route in symfony
I'm trying to redirect to the "/" route (same page) after a form submission:我试图在提交表单后重定向到“/”路由(同一页面):
/**
* @Route("/")
*/
My approach:我的做法:
return $this->redirectToRoute('/');
Gives me the following error:给了我以下错误:
Unable to generate a URL for the named route "/" as such route does not exist.
无法为命名路由“/”生成 URL,因为此类路由不存在。
you have to name the route, like:您必须命名路线,例如:
/**
* @Route("/", name="homepage")
*/
and then:进而:
return $this->redirectToRoute('homepage');
You can try this way:你可以试试这个方法:
/**
* @Route("/")
*/
return $this->redirect('/');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.