dongzai3917 2009-06-11 00:40
浏览 67
已采纳

为什么我的静态路由出现路由器错误?

I have in my bootstrap

public function initRoutes()
{
    $router = new Zend_Controller_Router_Rewrite();
    $route = new Zend_Controller_Router_Route_Static('register', array('module'=>'members','controller'=>'register','action'=>'index'));
    $router->addRoute('register',$route);
}

and when I go to http://domain.com/register

I get this error:

The following error occurred:

exception 'Zend_Controller_Dispatcher_Exception' with message 'Invalid controller specified (register)' in /var/www/html/beta/library/Zend/Controller/Dispatcher/Standard.php:241 Stack trace: #0 /var/www/html/beta/library/Zend/Controller/Front.php(936): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 /var/www/html/beta/application/bootstrap.php(24): Zend_Controller_Front->dispatch() #2 /var/www/html/beta/public/index.php(8): require_once('/var/www/html/b...') #3 {main}

in the modules/members/controllers directory there is a RegisterController.php with the class Members_RegisterController

I am not sure what I am doing wrong, I have referred to the manual on static routes and it seems that this should work

  • 写回答

1条回答 默认 最新

  • dongzhidian3538 2009-06-11 01:14
    关注

    Looks like you are adding a route to a router, but the router is not the one that belongs to your front controller. The router you created evaporates as soon as your initRoutes() function terminates.

    You must either use the default router of your front controller:

    $router = $frontCtrl->getRouter();
    $router->addRoute( ... );
    

    Or else if you create a new router, set that router to be the router for the front controller:

    $router = new Zend_Controller_Router_Rewrite();
    // ...add routes...
    $frontCtrl->setRouter($router);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 python变量和列表之间的相互影响
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)