How to Manually throw error Pages in Play Framework?

↘锁芯ラ 提交于 2019-12-10 23:33:01

问题


How do I manually throw a 404 or 500 error in Play framework 1.2.x?

I am currently rendering the 404.html and 500.html templates using renderTemplate() method. But how do I do it the proper way ?


回答1:


Play Controller has error() and notFound() methods for this purpose.




回答2:


In your controller you can just invoke static error() method from Controller which will give 500 status.




回答3:


return internalServerError(filledForm.errorsAsJson());



来源:https://stackoverflow.com/questions/10699595/how-to-manually-throw-error-pages-in-play-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!