Zend_Controller_Router_Exception: “xyz” is not specified

后端 未结 6 1584
野趣味
野趣味 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:20

    I've just encountered a problem similar to yours but have found a different workaround for it. I'll share it here just for the sake of information.

    Just like you, my problem seemed to be that my navigation was built using the route last used. This meant that if one of my custom routes had been used, I'd get a stack of exceptions complaining about some custom parameters for this given route not being defined.

    Most of my routes' custom parameters' value default to null in my route definition. I discovered if I changed the default value to '' instead, the exception would actually disappear. I couldn't really understand this so I began googling a bit and stumbled across your post which led me onto the right path - I think.

    My navigational elements are stored in a database so I generate all my Zend_Navigation_Page elements upon request and pass the container to my view helpers (I do serialize my container object to make it cacheable, but that's not relevant right now). I didn't really find that changing the params' default value to '' seeemed like a "good" way of doing it, so hinted by your post I tried to change all my page elements, stored in my database, to use a route named 'default' unless they explicitly was meant to use a custom route and had the params defined for it. Explicitly defining my navigational points to use the default route seemed to do the trick also and to me it seems as a more clean workaround.

    Thanks for the hint to what was causing this error - with the exception, I really had no clue about where to start :)

提交回复
热议问题