Julien Richard-Foy Julien Richard-Foy - 2 months ago 8
Scala Question

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

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

Answer

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))
  }
}