zf2路段问题与段

时间:2014-10-27 09:49:17

标签: zend-framework2

我尝试使用多个片段进行路由,如下所示

htpro / DOC /约会/ 15 /二千零十四分之十

'doc' => array(

                'type'    => 'segment',
                'options' => array(
                    'route'    => '/doc[/:action][/:app_day][/:app_month][/:app_year]',
                    'constraints' => array(
                        'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    ),
                    'defaults' => array(
                        'controller' => 'doc\Controller\Doc',
                        'action'     => 'appointments',
                    ),
                ),

            ),

但我得到了以下错误,可能是什么问题

路由无法匹配请求的网址。

1 个答案:

答案 0 :(得分:0)

试试这个:

'doc' => array(

            'type'    => 'segment',
            'options' => array(
                'route'    => '/htpro/doc[/:action][/:app_day][/:app_month][/:app_year]', //add /htpro
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'app_day' => '[0-9]*',   // add this 
                    'app_month' => '[0-9]*', // add this 
                    'app_year' => '[0-9]*',  // add this 
                ),
                'defaults' => array(
                    'controller' => 'doc\Controller\Doc',
                    'action'     => 'appointments',
                ),
            ),

        ),

但您仍需要定义自定义约束。