【发布时间】:2016-01-31 17:59:21
【问题描述】:
public class Main {
public static void main(String[] args) throws IOException, TemplateException{
Configuration freemarkerConfig = new Configuration();
freemarkerConfig.setClassForTemplateLoading(Main.class, "");
Template template = freemarkerConfig.getTemplate("template.ftl");
Map<String, String> data = new HashMap<String, String>();
for(int i=1;i<=10;i++){
data.put("map_"+i, "value"+i);
}
Writer out = new StringWriter();
template.process(data, out);
System.out.println(out.toString());
}
}
这是我访问变量的 FTL 代码:
<#assign containerIndex=1>
${map_containerIndex}
This gives error
I want to evaluate ${map_1}
【问题讨论】:
标签: java freemarker templating