php - CakePHP : Customized error message should display on the same page instead of moving some other page

标签 php cakephp error-handling

在cakephp中,我为错误4xx和5xx创建了自定义页面。它也正常工作。发生错误时,它会与错误消息一起导航到同一URL的另一页普通页面(请在此处找到图像)

)

我需要的是,如果发生错误,则它不应导航到该普通页面。错误消息应显示在同一页面上。尝试显示一些Flash消息,但不起作用!

在这里我创建的文件
错误/error400.ctp
错误/error500.ctp
布局/error.ctp

请帮助我实现这一目标!

最佳答案

只需关闭 Debug模式
Configure::write("debug",0)
编辑

如果要显示自定义错误页面,请执行此操作

function beforeRender () {
    if ($this->name == 'CakeError') { 
        $this->layout = 'error';
    }
}

如果您只想在页面本身上显示消息,请使用Flash消息

关于php - CakePHP : Customized error message should display on the same page instead of moving some other page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43999659/

相关文章:

cakephp:如何使 NOW() 在搜索条件下工作?

javascript - 当 promise 失败时如何捕捉?

python - 如何设置环境变量 R_user 以在 python 中使用 rpy2

.net - 发布网站: the resource cannot be found error

php - nginx 如何处理长时间运行的请求,如文件下载?

PHP 错误 'Array' 中的未知列 'field list' 和警告 : mysql_query() expects parameter 1 to be string?

php - CakePHP:-bash:蛋糕:找不到命令

php - 根据另一个表行比较MySQL表中的值

php - Advanced Rest 客户端中的数据数组响应无效

php - 将头像存储在mysql数据库中?