Hello, mi name is Igor. I saw that you good in Spark java.
I started to learn sparkjava with velocity template engine and faced with the problem, java can't find a template, which i put into public/templates/ folder. I say that staticFileLocation is ("/public"); So, java should find "templates" folder in "public" folder... But i have a wrong unable to find resource 'templates/layout.vm' in any resource loader And This is my tree structure
import java.util.HashMap;
import spark.ModelAndView;
import spark.template.velocity.VelocityTemplateEngine;
import static spark.Spark.*;
public class Main {
public static void main(String[] args) {
port(4567);
staticFileLocation("/public");
get("/", (request, response) -> {
return new ModelAndView(new HashMap(), "templates/layout.vm");
}, new VelocityTemplateEngine());
}
}
I have not found how to use staticFileLocation! Plz, help, thx!
A template is not static, so you should put it in resources/templates/layout.vm
You can look at this project if you still have trouble: https://github.com/perwendel/spark-template-engines
Oh, thank you very much!
What is mean, template is not static?ย
In which case template is static
ะกัะตะดะฐ, 19 ะพะบััะฑัั 2016, 18:07 +03:00 ะพั David [email protected]:
A template is not static, so you should put it in resources/templates/layout.vm
โ
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub , or mute the thread .
Static resources are resources that do not change (like images and css/javascript). The point of velocity files is that they are dynamic, you can define variables like $username and pass that from Java.
Hi Tipsy!
I'm facing the same issue with a Maven project, so I cloned the repository you provided. Im deploying to a local apache tomcat server 7.0 but no resources are found when I try to open it in the browser
Any idea?
Thanks in advance!
Pablo