2013-04-25 109 views
0

所以我工作的一個應用程序,我盡到一個控制器一些Ajax調用,並在沒有數據的情況下,拋出了404Zend公司拋404頭髮展模式

throw new Zend_Controller_Action_Exception('This page does not exist', 404); 

的問題是,我有$this->frontController->throwExceptions(true);所以在開發模式中會拋出一個錯誤,但它沒有設置404頭,並且我需要頭,因爲在基於頭的ajax調用中,我知道接下來會發生什麼。

有沒有辦法在開發模式下拋出404頭,throwExceptions設置爲true

回答

0

解決的辦法是撥打:->sendHeaders();

$this->getResponse()-> setHttpResponseCode(405)-> setRawHeader('HTTP/1.1 405 Method Not Allowed')->sendHeaders();