symfony2路由默认值

时间:2015-04-08 11:37:42

标签: php symfony symfony-routing

我已经定义了一个带注释的控制器

@Route("/add,{elId},{elType},{parentId}",name="MeaTask_Add", defaults={"elId"=null,"elType"=null, "parentId"=null})
public function addAction($elId=null, $elType=null, $parentId=null, Request $request){

我试着像这里一样使用它

$this->generateUrl('MeaTask_Add',array(
                    'parentId'=>$parentId         
                ))

并获取

  An exception has been thrown during the rendering of a template ("Parameter "elType" for route "MeaTask_Add" must match "[^/,]++" ("" given) to generate a corresponding URL.") 

1 个答案:

答案 0 :(得分:0)

@Route("/add/{elId}/{elType}/{parentId}",name="MeaTask_Add", defaults={"elId"=null,"elType"=null, "parentId"=null})

尝试使用斜杠我不会注释路径网址可以处理昏迷。