Serving index.html as static file from root folder

111 views
Skip to first unread message

Saša Vukšić

unread,
Nov 20, 2016, 2:48:31 PM11/20/16
to sparkjava
Hello,

In Spark 2.5.2 I have problem with serving index.html from root static folder when application is packaged as "fat .jar". When I call http:/localhost:4567/ url I get index.html for download as a file but not showing as a page. That happens only when aplication is in .jar format, when I try that from Eclipse everything works fine.

With Spark version 2.3 I didn't have the same problem.

Does anyone have any advice?

Sasa

domin...@gmail.com

unread,
Jan 9, 2017, 9:25:09 AM1/9/17
to sparkjava
Stream it.

get("/", new Route() {
 
public Object handle(Request request, Response response) throws Exception {
   
return IOUtils.toString(Spark.class.getResourceAsStream("/index.html"));
   
}
});

Reply all
Reply to author
Forward
0 new messages