I am using play framework 2.3 version and providing static html(Not using play template engine).
#Map static resources from the /public folder to the /assets URL path GET /assets/*file controllers.Assets.at(path="/public", file)
I would like to provide 404 page when user try to access wrong url
for example i have 2 html in public assets folder.
public/html/a.html
public/html/b.html
public/error/404.html
URL: localhost/assets/html/a.html -> 200 OK
URL: localhost/assets/html/b.html -> 200 OK
URL: localhost/assets/html/c.html -> 404 NOT FOUND PAGE so i would like to provide this page (URL: localhost/assets/error/404.html)
I already try to use Global.onHandlerNotFound and Global.onBadRequest But this is not working in case of static resources.
Please help me. Thank you.
First of all, put your static html for 404 error at public/ folder, e.g (public/error404.html)
Then, at onHandlerNotFound method, which Play docs tell is supposed to be called
You'll return that page. So, you can return it that way
I think i had misunderstood your question.
Take notice that this method is supposed to handle not found Actions. If you want to handle not found assets, then I think you must modify the built-in Assets controller, once there it is, the action that handle assets responses , the Assets.at action. If there's no asset ir probably just calls Results.notFound(). It doesn't call any global method so you could handle the error, that's the point.