Reputation: 459
I'm very new to Spark. Will anyone please tell me how can I map external static resources? I am aware of the below method gotten from here :
public static synchronized void externalStaticFileLocation(String
externalFolder) {
if (initialized) {
throwBeforeRouteMappingException();
}
externalStaticFileFolder = externalFolder;
}
But I do not know how to use it. I called it before Routing like
externalStaticFileLocation("/resources/*");
I also tried
staticFileLocation("css/CrudTemp.css");
staticFileLocation("js/jquery.js");
staticFileLocation("js/jquery-ui.js");
Also tried
Spark.staticFileLocation("src/main/resources/css");
Spark.staticFileLocation("src/main/resources/js");
Upvotes: 3
Views: 1800
Reputation: 459
I solved it by Creating public folder under src/main/resources and then mapped it like
staticFileLocation("/public");
and then in template file i access that resources like
css/file.css
js/file.js
and it worked... but still i do not know why it did not worked for above methods described in questions
Upvotes: 3