Playframework 调用notFound()时,404和500错误视图(404.html和505.html)不呈现
我已将范围缩小到添加路线时: /{userid}Application.blah 在函数Application.blah中,我认为我通过使用notFoundIfNulluser来处理它 我的问题是,每当我在网站中输入一个随机URL时,我只会返回文本Playframework 调用notFound()时,404和500错误视图(404.html和505.html)不呈现,playframework,playframework-1.x,Playframework,Playframework 1.x,我已将范围缩小到添加路线时: /{userid}Application.blah 在函数Application.blah中,我认为我通过使用notFoundIfNulluser来处理它 我的问题是,每当我在网站中输入一个随机URL时,我只会返回文本 在生产环境中找不到,而不是呈现的404.html页面Hmm,在controllers.Application.java中使用以下内容: public static void blah (String userid) { User test=n
在生产环境中找不到,而不是呈现的404.html页面Hmm,在controllers.Application.java中使用以下内容:
public static void blah (String userid)
{
User test=null;
try{
test = User.findById(userid);
} catch(Exception e)
{
//lookup exception!
}
notFoundIfNull(test);
}
my route.conf包含以下内容:
GET /{userid} Application.blah
我可以查看我的/apps/views/errors/404.html,其中包含以下内容:
#{if !play.mode.name() == 'DEV'}
...insert production 404 here...
#{/if}
如果您的格式与此匹配,那么问题可能与您在生产404中调用的内容有关。对于我的403页面,我发现如果调用${response.reason},它只使用我的403响应呈现整个页面,如下所述:。祝你好运 您是否创建了自己的404/500页面或自定义了现有页面?这应该在PROD模式下工作…什么是Accept:生成404的请求的头?如果它不同于text/html和其他一些变体,它可能会尝试呈现404.tag而不是404.html。