如何在zf2中編寫允許zf1中的/:controller/:action/*
等路由的路由?如何在ZF2中編寫一個滿足GET參數要求的路線?
如此才能滿足像controller/action/id/1/page/2
和controller/action?id=1&page=2
參數?
一條迎合參數的路線,如controller/action?id=1&page=2
世界對於ajax請求很有用。
所以我當前的代碼看起來像這樣在我module.config.php
return array(
'controllers' => array(
'invokables' => array(
'Support\Controller\Support' => 'Support\Controller\SupportController',
),
),
'router' => array(
'routes' => array(
'support' => array(
'type' => 'segment',
'options' => array(
'route' => '/support[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Support\Controller\Support',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'support' => __DIR__ . '/../view',
),
),
非常感謝您的回覆。我將我的應用程序從「骨架應用程序」中刪除,並閱讀了您提供的幻燈片演示鏈接。它確實表示它支持可選分段(文字和參數部分)的分段路由。 我只是不太確定如何。也許我錯過了一些基本的東西。 – Kenneth