How to create a custom 404 page handler with Play 2.0?

后端 未结 7 2146
故里飘歌
故里飘歌 2021-01-03 19:22

What’s the preferred way to handle 404 errors with Play 2.0 and show a nice templated view?

7条回答
  •  無奈伤痛
    2021-01-03 19:52

    This works in 2.2.1. In Global.java:

    public Promise onHandlerNotFound(RequestHeader request) {
        return Promise.pure(notFound(
            views.html.throw404.render()
        ));
    }
    

    Ensure that you have a view called /views/throw404.scala.html

提交回复
热议问题