【发布时间】:2012-05-09 18:22:11
【问题描述】:
使用此代码:
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$router->addRoute(
'test',
new Zend_Controller_Router_Route(
'/test/:action/:type/:id',
array(
'controller' => 'admin'
)
)
);
http://app/test/param1/param2/param3 -> 好的
http://app/test/param1/param2/ -> 失败
在第二种情况下,应用程序无法识别 param2。
似乎应用程序需要 param3 才能读取 param2...
我该怎么做?
谢谢!
使用来自@RageZ 的代码进行测试
$frontController = Zend_Controller_Front::getInstance();
$router = $frontController->getRouter();
$router->addRoute(
'test',
new Zend_Controller_Router_Route(
'/test/:action/:type/:id',
array(
'controller' => 'admin',
'id' => 0
),
array(
'id' => '\d+'
)
)
);
http://app/test/ -> 好的
http://app/test/some -> 好的
http://app/test/some/more -> 失败
http://app/test/some/more/andmore -> 好的
想法?
【问题讨论】:
-
最后一个代码缺少类型的默认值... ;)