Configuration cfg = new Configuration(Configuration.VERSION_2_3_31); cfg.setClassForTemplateLoading(getClass(), "/templates"); Template template = cfg.getTemplate("index.ftl"); Map<String, Object> dataModel = new HashMap<>(); dataModel.put("name", "John Doe"); dataModel.put("age", 25); StringWriter stringWriter = new StringWriter(); template.process(dataModel, stringWriter); String output = stringWriter.toString();


上一篇:
下一篇:
切换中文