[英]Zend_Controller_Router_Route_Regex not working
I'm trying to use the Zend_Controller_Router_Route_Regex in an application but it doesn't seem to be working at all. 我正在尝试在应用程序中使用Zend_Controller_Router_Route_Regex,但它似乎根本无法正常工作。
I've set up a very basic instance: 我已经建立了一个非常基本的实例:
$route = new Zend_Controller_Router_Route_Regex(
'/developer/test/(d+)',
array('controller' => 'developer', 'action' => 'module','module'=>'topic')
);
$router->addRoute('apiModule2', $route);
and the corresponding action: 以及相应的动作:
public function moduleAction()
{
$this->view->module = 'topic';
}
However, every time I visit localhost/developer/test/1, I get a No Route Matched exception. 但是,每次访问localhost / developer / test / 1时,都会出现“无路由匹配”异常。
I believe this is all set up properly because if I use the same exact code changing only Zend_Controller_Router_Route_Regex to Zend_Controller_Router_route and the match url to match against to 'developer/test/1' it all works perfectly. 我相信这一切都已正确设置,因为如果我使用相同的完全相同的代码,仅将Zend_Controller_Router_Route_Regex更改为Zend_Controller_Router_route,并且将匹配URL匹配为'developer / test / 1',那么它们都可以正常工作。
Any ideas what could be going on? 有什么想法怎么回事?
Thanks! 谢谢!
The correct route to match 正确的匹配路线
http://localhost/developer/test/1
http:// localhost / developer / test / 1
is 是
$route = new Zend_Controller_Router_Route_Regex(
'developer/test/(\d+)',
array('controller' => 'developer', 'action' => 'module','module'=>'topic')
);
You should not have leading slash(before the developer) and d+ should be \\d+. 您不应该在开发人员之前使用斜杠,并且d +应该是\\ d +。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.