mustache模板引擎

48 阅读1分钟

1、引入依赖

org.springframework.boot spring-boot-starter-mustache 2、测试代码

public static void main(String[] args) throws IOException { HashMap<String, Object> scopes = new HashMap<String, Object>(); scopes.put("ceshi", "显示结果");

Writer writer = new OutputStreamWriter(System.out);
MustacheFactory mf = new DefaultMustacheFactory();
Mustache mustache = mf.compile(new StringReader("{{ceshi}}"), "example");
mustache.execute(writer, scopes);
writer.flush();

} 3、可以配合富文本编辑器

image.png