[英]same name function in different controller in symfony2 is not work in different path
this is UserController file 这是UserController文件
class UsersController extends Controller
{
/**
* @Route("/users", name="indexAction")
*/
public function indexAction()
{
$em = $this->getDoctrine()->getManager();
$users = $em->getRepository('AppBundle:Users')->findAll();
return $this->render('admin/users.htmls.twig', array('users'=>$users));
}
/**
* @Route("/users/add", name="addAction")
*/
public function addAction()
{
return $this->render('admin/addusers.html.twig');
}
}
and this is CmsController file: 这是CmsController文件:
class CmsController extends Controller
{
/**
* @Route("/cms", name="cmsAction")
*/
public function cmsAction()
{
$em = $this->getDoctrine()->getManager();
$cms= $em->getRepository('AppBundle:Cms')->findAll();
return $this->render('admin/mcs.htmls.twig', array('cms'=>$cms));
}
/**
* @Route("/cms/add", name="addAction")
*/
public function addAction()
{
return $this->render('admin/addcms.html.twig');
}
}
see the difference if i set addAction function not work but i set different name is work properly plz help how to call same name 看到差异,如果我设置addAction功能不起作用,但我设置不同的名称是正常工作PLZ帮助如何调用相同的名称
The internal route names need to be unique, please see symfony: routing : 内部路由名称必须是唯一的,请参阅symfony:routing :
The [annotation name] is the internal name of the route, which doesn't have any meaning yet and just needs to be unique. [注释名称]是路径的内部名称,它没有任何意义,只需要是唯一的。 Later, you'll use it to generate URLs. 稍后,您将使用它来生成URL。
This issue is mainly caused due to the same routs. 此问题主要是由于相同的路径引起的。 As we can see your routes are fine please check you have enabled the mod_rewrite module on. 我们可以看到您的路线很好,请检查您是否启用了mod_rewrite模块。 If that does not solve your problem you can generate an issue on there official issue tracker on GitHub on the provided link https://github.com/symfony/symfony/issues/ 如果这不能解决您的问题,您可以在提供的链接上的GitHub上的官方问题跟踪器上生成问题https://github.com/symfony/symfony/issues/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.