After I add templates dependency to
pom.xml:
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-template-freemarker</artifactId>
<version>2.3</version>
</dependency>
So far, I want to know where should I put hello.mustache and hello.ftl to which folders ?
src/main/resources/hello.ftl ?
But, This path not working. Should I add the code ?
FreeMarkerEngine freeMarkerEngine = new FreeMarkerEngine();
Configuration freeMarkerConfiguration = new Configuration();
freeMarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(App.class, "/"));
freeMarkerEngine.setConfiguration(freeMarkerConfiguration);
After specified the public resource folder, How to config the templates path ? This problem really annoyed me.
if (LOCAL) {
String projectDir = System.getProperty("user.dir");
String staticDir = "/src/main/resources/public";
Spark.staticFiles.externalLocation(projectDir + staticDir);
} else {
Spark.staticFiles.location("/public");
}
Should I put the template to
src/main/resources/public/hello.ftl ?
Should I configure freemarker to :
freeMarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(App.class, "/public"));
But It still dit not work ... How to config freemarkder, and which folder should I put the templates to?