1、引入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mustache</artifactId> </dependency>
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、可以配合富文本编辑器