在过去的两个小时里,我一直在努力解决这个问题。我正在尝试向我的Zend (V1)应用程序添加regex路由。我的其他路由是静态的,并存储在我的application.ini文件中,这就是我想要放置一些新的regex路由的地方。
在继续处理更复杂的regex路由之前,我开始将以下(工作)路由转换为regex路由:
resources.router.routes.shift-display.route = /shift/display/:id
resources.router.routes.shift-display.defaults.module = shift
resources.router.routes.shift-display.defaults.controller = index
resources.router.routes.shift-display.defaults.action = display以下是我想出的:
resources.router.routes.shift-display.type = "Zend_Controller_Router_Route_Regex"
resources.router.routes.shift-display.regex = "shift/display/(\d+)"
resources.router.routes.shift-display.defaults.module = shift
resources.router.routes.shift-display.defaults.controller = index
resources.router.routes.shift-display.defaults.action = display
resources.router.routes.shift-display.map.1 = id
resources.router.routes.shift-display.reverse = "shift/display/%d"但这不管用。路由似乎没有被路由器识别。当尝试打开(例如vh.localhost/shift/display/7 )时,我会得到“指定的无效控制器(显示)”,因此路由器使用默认路由。我还试着用斜线来抢占regex路线。我尝试使用url-helper来使用新的regex路由生成链接(带有传递的ID param),而且它可以工作。
有人有线索吗?
发布于 2014-02-13 15:16:53
有时候就这么简单。在确定路线时,在这一行中犯了错误:
resources.router.routes.shift-display.regex = "shift/display/(\d+)"一定是
resources.router.routes.shift-display.route = "shift/display/(\d+)"4个小时什么都没做。但至少我终于找到了-)
https://stackoverflow.com/questions/21744113
复制相似问题