[英]ZF2 Child routes not working
在阅读了有关路由的大量文章之后,我仍然无法使其工作。
当我这样做时,我可以转到“ /门户”:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
),
但是当我像这样添加child_routes时:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
),
'defaults' => array(
'__NAMESPACE__' => 'Portal\Controller',
'action' => 'index'
),
),
),
),
),
我仍然能够转到“ / portal”,但是当我转到“ / portal / activities / index”(相同)时,我得到“找不到页面”。
希望有人能帮忙
提前致谢!
段定义不正确,缺少/,因此当前完整的子路由为/ portal [:controller [/:action]]
将其更改为:
'portal' => array(
'type' => 'Literal',
'options' => array(
'route' => '/portal',
'defaults' => array(
'controller' => 'Portal\Controller\Activities',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '/[:controller[/:action]]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*'
),
'defaults' => array(
'__NAMESPACE__' => 'Portal\Controller',
'action' => 'index'
),
),
),
),
),
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.