What’s the preferred way to handle 404 errors with Play 2.0 and show a nice templated view?
To display a custom error page with an appropriate error code, use the <httpErrors> section only, and do not use the <customErrors> section. Add the following <httpErrors> section under <system.
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)) } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With