Zend_Controller_Router_Exception: “xyz” is not specified

后端 未结 6 1580
野趣味
野趣味 2020-12-11 07:23

I have a problem in my current Zend Framework application.

In my Bootstrap I register these routes:

protected function _initRouter()
{
    $this->         


        
6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-11 08:27

    I found the solution myself.

    This problem was caused due to a not-so-beneficial behavior of the Zend_Navigation elements. In their getHref() method they use the URL helper. This helper creates the URL the navigation entry has to link to, taking in the arguments specified for the navigation element (module, controller, action, etc.)

    Now, the problem is that, if you have created a custom route in your bootstrap just as I did, for example

    ":module/:controller/:id"
    

    You run into the problem that when this route is being used, the URL helper uses that route to generate the link for the navigation entry. However, I did not pass on an additional "id" parameter, so I got the exception.

    So one solution is to pass an additional parameter for each Zend_Navigation_Page_Mvc instance "route" which is set to "default".

    Another solution, which I didn't try yet, is to let the new custom route just re-map itself onto the default route, like:

    ":module/:controller/:action/id/$id"
    

    But I don't know if you have the ability with Zend Framework to do that.

提交回复
热议问题