简体   繁体   English

如何在Play框架中手动抛出错误页面?

[英]How to Manually throw error Pages in Play Framework?

How do I manually throw a 404 or 500 error in Play framework 1.2.x? 如何在Play框架1.2.x中手动抛出404500错误?

I am currently rendering the 404.html and 500.html templates using renderTemplate() method. 我目前正在使用renderTemplate()方法渲染404.html500.html模板。 But how do I do it the proper way ? 但是我该如何以正确的方式做到这一点?

Play Controller具有用于此目的的error()notFound()方法。

在您的控制器中,您只需从Controller调用静态error()方法,该方法将提供500状态。

return internalServerError(filledForm.errorsAsJson());

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM