我有一個基於Zend Framework 2的大型網站。URL遵循domain.tld/module/action/otherstuff的標準模式。ZF2如何顯示錯誤404爲不可伸縮動作
如果有人鍵入一個不存在的模塊,他們會得到一個標準的404頁未找到消息。但是,如果用戶進入一個有效的模塊,而是進入一個無效的動作名稱,他們得到的消息
Zend\View\HelperPluginManager::get was unable to fetch or create an instance for escape
我怎麼能輸出一個正常的404錯誤消息,而不是此消息?我猜測我沒有在某處正確地捕捉到某些東西,但我不知道從哪裏開始尋找。
這裏是堆棧跟蹤:
C:\conversion\vendor\zendframework\zendframework\library\Zend\ServiceManager\ServiceManager.phpLine #495
#0 C:\conversion\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php(103): Zend\ServiceManager\ServiceManager->get('escape', true)
#1 C:\conversion\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php(378): Zend\ServiceManager\AbstractPluginManager->get('escape', NULL)
#2 C:\conversion\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php(397): Zend\View\Renderer\PhpRenderer->plugin('escape')
#3 C:\conversion\module\Supplier\view\error\404.phtml(56): Zend\View\Renderer\PhpRenderer->__call('escape', Array)
#4 C:\conversion\module\Supplier\view\error\404.phtml(56): Zend\View\Renderer\PhpRenderer->escape('Supplier\Contro...')
#5 C:\conversion\vendor\zendframework\zendframework\library\Zend\View\Renderer\PhpRenderer.php(507): include('C:\conversio...')
#6 C:\conversion\vendor\zendframework\zendframework\library\Zend\View\View.php(205): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))
#7 C:\conversion\vendor\zendframework\zendframework\library\Zend\View\View.php(233): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#8 C:\conversion\vendor\zendframework\zendframework\library\Zend\View\View.php(198): Zend\View\View->renderChildren(Object(Zend\View\Model\ViewModel))
#9 C:\conversion\vendor\zendframework\zendframework\library\Zend\Mvc\View\Http\DefaultRenderingStrategy.php(102): Zend\View\View->render(Object(Zend\View\Model\ViewModel))
#10 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Object(Zend\Mvc\MvcEvent))
#11 C:\conversion\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(468): call_user_func(Array, Object(Zend\Mvc\MvcEvent))
#12 C:\conversion\vendor\zendframework\zendframework\library\Zend\EventManager\EventManager.php(207): Zend\EventManager\EventManager->triggerListeners('render', Object(Zend\Mvc\MvcEvent), Array)
#13 C:\conversion\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(347): Zend\EventManager\EventManager->trigger('render', Object(Zend\Mvc\MvcEvent))
#14 C:\conversion\vendor\zendframework\zendframework\library\Zend\Mvc\Application.php(322): Zend\Mvc\Application->completeRequest(Object(Zend\Mvc\MvcEvent))
#15 C:\conversion\public\index.php(25): Zend\Mvc\Application->run()
#16 {main}
您可以發佈您完整的堆棧跟蹤? zf2中沒有'逃生'視圖助手。看起來像你的一個視圖文件搞亂了某個地方。 – radnan
添加堆棧跟蹤 – Wige
用escapeHtml()替換#4中的escape()。 – radnan