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

后端 未结 7 2089
故里飘歌
故里飘歌 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:00

    You can override the onHandlerNotFound method on your Global object, e.g.:

    object Global extends GlobalSettings {
      override def onHandlerNotFound(request: RequestHeader): Result = {
        NotFound(views.html.notFound(request))
      }
    }
    

提交回复
热议问题