【问题标题】:symfony2 routing defaultssymfony2 路由默认值
【发布时间】:2015-04-08 11:37:41
【问题描述】:

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

@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.") 

【问题讨论】:

    标签: php symfony symfony-routing


    【解决方案1】:
    @Route("/add/{elId}/{elType}/{parentId}",name="MeaTask_Add", defaults={"elId"=null,"elType"=null, "parentId"=null})
    

    尝试使用斜线,因为注释路由 url 无法处理昏迷。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-16
      • 2014-05-03
      • 1970-01-01
      • 2017-01-15
      • 2016-01-18
      • 2013-09-06
      • 1970-01-01
      相关资源
      最近更新 更多