你好,我是cakepp的新手,如果有人在我的cakepp应用程序中输入了错误的url,我想显示一个错误页面。
我正在根据互联网上的给定示例使用此代码
CakePHP 2.0-如何制作自定义错误页面?
我无法在我的应用程序中看到任何自定义错误页面。我已经使用了在该url 中添加的所有给定步骤
尝试第二个答案:
自定义404错误页面的内容而不需要自定义逻辑,只需编辑app/View/Errors/error400.ctp.的内容
请注意,您还需要将调试级别设置为零才能查看自定义错误页面。
最好的方法是处理AppController.php 中的所有错误
public function beforeRender() {
parent::beforeRender();
if ($this->name == 'CakeError') {
$this->redirect(array(
'controller' => 'ExampleController', 'error_action'));
}
}
并使视图view/ExampleController/error_action.ctp符合您的需要。