Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
String content = "标题:${title}" +
"内容:${content}";
final ByteArrayTemplateLoader templateLoader = new ByteArrayTemplateLoader();
templateLoader.putTemplate("test.ftlh", content.getBytes());
cfg.setTemplateLoader(templateLoader);
Template template = cfg.getTemplate("test.ftlh");
System.out.println(template.toString());
Map map = new HashMap();
map.put("title", 123);
map.put("content", 123);
String s1 = FreeMarkerTemplateUtils.processTemplateIntoString(template, map);
System.out.println(s1);