package com.wxl.app.freemarker;
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.Map;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
public class SimpleTemplate {
public String process(String path, Map<String, Object> map) throws IOException, TemplateException {
Configuration cfg = new Configuration();
cfg.setDirectoryForTemplateLoading(new File("E:/java/freemarker/freemarker-2.3.19/freemarker-2.3.19/examples/webapp1/WEB-INF/templates"));
Template template = cfg.getTemplate(path);
StringWriter sw = new StringWriter();
template.process(map, sw);
return sw.toString();
}
}
freemarker helloworld
最新推荐文章于 2023-06-08 08:34:37 发布