我有一個與cakephp 2.x重定向的問題。CakePHP重定向到空白頁面
當我執行重定向下方的功能,它完美的作品:
public function test() {
$this->redirect(array('controller' => 'pages','action' => 'index'));
}
但是,當我執行trasaction與數據庫(添加,修改和刪除),函數重定向我到一個空白頁:
public function delete($id = null) {
$this->Post->id = $id;
if (!$this->Post->exists()) {
throw new NotFoundException(__('Invalid post'));
}
if ($this->Post->deleteAll(array('Post.id' => $id), false)) {
$this->Session->setFlash(__(" success."), 'flash', array('class' => 'alert alert-success'));
} else {
$this->Session->setFlash(__("error."), 'flash', array('class' => 'alert alert-danger'));
}
$this->redirect(array('controller' => 'pages','action' => 'index'));
}
重定向不起作用。 感謝您的幫助
你試過重定向到不同的控制器嗎? –
「空白頁」是什麼意思?瀏覽器中的網址是「/ pages/index」還是有些不同?您是否檢查過CakePHP文件夾中的錯誤日誌文件?您是否在瀏覽器中使用webdeveloper工具檢查了HTTP響應代碼(什麼錯誤代碼,例如404/500)?可能空白頁是由重定向的目的地引起的(在你的頁面控制器中的索引動作)?... –