I use Spark to serve a webpage. For static files, I initialize Spark as here ::
So, I have this structure:
/src/main/resources/public/ |-- foo/ |-- css/ | |-- bootstrap.css |-- js/ | ... |-- img/ ...
I made a foo folder to do the trick because my webpage is under /foo url..like this:
http://www.example.com/foo/index
So, my static files are loaded as follows:
http://www.example.com/foo/css/bootstrap.css
Now I want to have this path variable. Since I have different environments and, for example, if I deploy this application in a different domain, I want this to be:
http://www.example2.com/superfoo/css/bootstrap.css
But for this I have to change the release and change the folder ...
For controllers, I made it easy:
Example:
Spark.get(this.appBasePath + "/users", (request, response) -> { return this.getUsersView(request); }, new FreeMarkerEngine());
this.appBasePath comes from the configuration that loads when the environment is this.appBasePath .
So I ask you to set the programmatic URL of static files without creating any folder. Is there any way to achieve this?
java spark-java
Pablo Matias Gomez
source share