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

后端 未结 7 2088
故里飘歌
故里飘歌 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 20:08

    This works in 2.2.3 Play - Java

    public Promise<SimpleResult> onHandlerNotFound(RequestHeader request) {
        return Promise<SimpleResult>pure(Results.notFound(views.html.notFound404.render()));
    }
    

    html should be within /views/notFound404.scala.html Dont forget to add Results.notFounf() and import play.mvc.Results;

    0 讨论(0)
提交回复
热议问题