路由到多个操作

时间:2012-04-01 08:15:18

标签: zend-framework routing

我想路由到多个操作,我在application.ini文件上进行路由配置。

resources.router.routes.blog.route = /blogs
resources.router.routes.blog.defaults.module = blogs
resources.router.routes.blog.defaults.controller = blog
resources.router.routes.blog.defaults.action = index


resources.router.routes.blog.route = /blogs/add
resources.router.routes.blog.defaults.module = blogs
resources.router.routes.blog.defaults.controller = blog
resources.router.routes.blog.defaults.action = add

当我这样做时,默认路由/博客返回错误

Message: Invalid controller specified (index)

 array (
  'module' => 'blogs',
  'controller' => 'index',
  'action' => 'index',
)  

1 个答案:

答案 0 :(得分:0)

您的路线名称相同,请将路线调整为类似:

//the 4th parameter is the name of the route and needs to be unique for each different route
resources.router.routes.blogs.route = /blogs
resources.router.routes.blogs.defaults.module = blogs
resources.router.routes.blogs.defaults.controller = blog
resources.router.routes.blogs.defaults.action = index


resources.router.routes.blogsadd.route = /blogs/add
resources.router.routes.blogsadd.defaults.module = blogs
resources.router.routes.blogsadd.defaults.controller = blog
resources.router.routes.blogsadd.defaults.action = add