标签:etc 3.0 lease tca work pre mod context string
thymeleaf动态模板:
Map data = new HashMap(); data.put("code", "1234"); SpringTemplateEngine springTemplateEngine = new SpringTemplateEngine(); //IDialect iDialect = new SpringStandardDialect(); //springTemplateEngine.setDialect(iDialect); StringTemplateResolver stringTemplateResolver = new StringTemplateResolver(); stringTemplateResolver.setCacheable(true); stringTemplateResolver.setTemplateMode(TemplateMode.HTML); springTemplateEngine.setTemplateResolver(stringTemplateResolver); Context context = new Context(); context.setVariables(data); String content = "短信验证码为:<span th:utext=\"${code}\"></span>,5分钟内有效"; String result = springTemplateEngine.process(content, context);
pom文件引入:
<dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf</artifactId> <version>3.0.9.RELEASE</version> </dependency>
若直接引入:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> <version>2.0.4.RELEASE</version> </dependency>
那么如果spring-boot的版本是2.0以下的会有问题
标签:etc 3.0 lease tca work pre mod context string
原文地址:https://www.cnblogs.com/tiramisuyj/p/9521152.html