Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Playframework 如何在play2.0框架中创建自定义编译错误页?_Playframework_Playframework 2.0 - Fatal编程技术网

Playframework 如何在play2.0框架中创建自定义编译错误页?

Playframework 如何在play2.0框架中创建自定义编译错误页?,playframework,playframework-2.0,Playframework,Playframework 2.0,我想用我自己的错误消息自定义我的编译错误消息页面 我该怎么做?在play 2.0中,编译错误页将在何处配置 提前感谢。您最好创建自己的全局对象,重载onError(…),并呈现自己的页面,而不是默认页面 详细信息可在文档中找到 考虑到默认错误页面是多么有用,我喜欢在开发时保留这些错误,并在生产中显示一些更加用户友好的内容。因此,我通常会这样做: public class Global extends GlobalSettings { @Override public Result

我想用我自己的错误消息自定义我的编译错误消息页面

我该怎么做?在play 2.0中,编译错误页将在何处配置


提前感谢。

您最好创建自己的全局对象,重载onError(…),并呈现自己的页面,而不是默认页面

详细信息可在文档中找到

考虑到默认错误页面是多么有用,我喜欢在开发时保留这些错误,并在生产中显示一些更加用户友好的内容。因此,我通常会这样做:

public class Global extends GlobalSettings {
    @Override
    public Result onError(Http.RequestHeader requestHeader, Throwable throwable) {        
        if (Application.isDevelopment()) {
            return super.onError(requestHeader,throwable);
        }
        // customer facing
        Application.sendErrorEmail("Error occurred on production server: "+throwable.getMessage());
        // give the customer a reasonable message without giving away any internal details
        return internalServerError("Sorry, but an unexpected error occurred.  Please contact the administrator if this error continues.");
    }

    ...
}