1
我已经定义了两个路由,/ shoppingcart /和一个子路由/ shoppingcart/add /,它们只能用于POST请求。Zend Mvc Router Http 方法和子路由
'routes' => array(
'shoppingcart' => array(
'type' => 'literal',
'options' => array(
'route' => '/shoppingcart/',
'defaults' => array(
'controller' => 'ShoppingcartController',
'action' => 'shoppingcart',
),
),
'may_terminate' => true,
'child_routes' => array (
'add-product' => array(
'type' => 'method',
'options' => array(
'verb' => 'post',
'route' => 'add/',
'defaults' => array(
'controller' => 'ShoppingcartController',
'action' => 'addProductToShoppingcart',
),
),
),
)
),
)
路线/ shoppingcart /工作正常。子路由/ shoppingcart/add /不起作用(POST和GET发生404错误)。
当我从方法更改类型到文字并删除它的动词键它的作品。
如何在子路径中使用Zend \ Mvc \ Router \ Http \ Method?
我首先认为这将修复它,但我喜欢的类型设置为文本。它仍然具有与type = literal类似的行为,但不具有type = method。 – Weteef 2013-03-22 09:52:09
@ Weteef,对不起,请参阅编辑的版本 – Crisp 2013-03-22 17:09:03
太棒了,它的工作原理!非常感谢! – Weteef 2013-03-23 10:52:01