重定向到 symfony 中的“/”路由
Redirect to "/" route in symfony
我正在尝试在提交表单后重定向到“/”路由(同一页面):
/**
* @Route("/")
*/
我的做法:
return $this->redirectToRoute('/');
给我以下错误:
Unable to generate a URL for the named route "/" as such route does not exist.
你必须给路线命名,例如:
/**
* @Route("/", name="homepage")
*/
然后:
return $this->redirectToRoute('homepage');
你可以这样试试:
/**
* @Route("/")
*/
return $this->redirect('/');
我正在尝试在提交表单后重定向到“/”路由(同一页面):
/**
* @Route("/")
*/
我的做法:
return $this->redirectToRoute('/');
给我以下错误:
Unable to generate a URL for the named route "/" as such route does not exist.
你必须给路线命名,例如:
/**
* @Route("/", name="homepage")
*/
然后:
return $this->redirectToRoute('homepage');
你可以这样试试:
/**
* @Route("/")
*/
return $this->redirect('/');