springboot-thymeleaf动态模板生成
2021-07-19 21:06
标签:etc 3.0 lease tca work pre mod context string thymeleaf动态模板: pom文件引入: 若直接引入: 那么如果spring-boot的版本是2.0以下的会有问题 springboot-thymeleaf动态模板生成 标签:etc 3.0 lease tca work pre mod context string 原文地址:https://www.cnblogs.com/tiramisuyj/p/9521152.htmlMap 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 = "短信验证码为:,5分钟内有效";
String result = springTemplateEngine.process(content, context);
上一篇:python--Email提醒
下一篇:java中使用redis