I guess you are looking for Scala code for Global.scala
to display your own 404 Page.
Global.scala
should be under your /views
folder. And override the onHandlerNotFound
method in it, like this:
override def onHandlerNotFound(request: RequestHeader) = {
var cookies: Seq[Cookie] = Seq()
Future.successful(NotFound("hello world!!!!").withCookies(cookies:_*))
}
The NotFound
is a PageCtrl.Status
method which may need a import at the top of Global.scala
. You can try using NotFound("Hello World")
to see what's happening. It will display pure text "hello world"
instead of default 404 page.
So the final code should be like
override def onHandlerNotFound(request: RequestHeader) = {
var cookies: Seq[Cookie] = Seq()
Future.successful(NotFound(view.html.yourOwn404PageHtml).withCookies(cookies:_*))
}
The withCookies
is just used to create a Result
object. You can use other method belongs to NotFound()
.