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.
The router will invoke the Assets.at action with the following parameters:
controllers.Assets.at("public", "javascripts/jquery.js")This action will look-up the file and serve it, if it exists.
Play Assets controller look-up file in public folder and serve But i would like to know if play can not find file how i can control for my 404 page.--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to play-framewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
public static Result at(String path, String file) {
File asset = Play.application().getFile(Paths.get(path, file).toString());
if(asset.exists()) {
return ok(asset, true);
} else return ok(Play.application().getFile("/public/error/404.html"), true);
}
--
You received this message because you are subscribed to a topic in the Google Groups "play-framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/play-framework/GmBxttVBTXY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to play-framewor...@googlegroups.com.
