Total Pageviews

2020/05/06

[Apache Freemarker] How to load freemarker template

Scenario 1: Set freemarker template from classpath


code snippet:
    // Set freemarker template from classpath
    Configuration cfg = new Configuration();
    cfg.setClassForTemplateLoading(this.getClass(), "/");


Scenario 2: Set freemarker template from directory


code snippet:
    // Set freemarker template from directory
    Configuration cfg = new Configuration();
    File ftlDir = new File("deliverable/ftl/");
    cfg.setDirectoryForTemplateLoading(ftlDir);


No comments: