【发布时间】:2011-03-23 17:06:48
【问题描述】:
下面是我的Jar 文件的结构
root
- template.ftl
- org.project.myproject.App.java
在 App.java 中,我有一行代码希望我指定 directory 以加载 template.ftl。比如:
Line#1: cfg.setDirectoryForTemplateLoading("java.io.File object that represents /directory/for/storing/template/files");
以及下一行代码,读取模板文件
Line#2: Template temp = cfg.getTemplate("template.ftl");
我的问题是我无法指定加载文件的目录路径。要加载的模板文件位于Jar 的根目录中。写的时候,
cfg.setDirectoryForTemplateLoading(new File("."));
上面写着,template.ftl 未找到。
上面Line#1处可以正确设置模板目录的合适代码应该是什么?
【问题讨论】:
标签: java freemarker