【发布时间】:2021-01-28 01:22:19
【问题描述】:
我们需要动态解析 html 或文本模板。具有可变占位符的模板内容(字符串)将在数据库中可用。
我们必须根据需要使用变量的实际值动态解析它们并获得最终的字符串内容。
示例:(不是完整的代码)
String myHtmlTemplateContent = "<h1>Hi ${first_name} ${last_name}</h1>";
Map<String, Object> myMapWithValues = ..;
engine.resolve(myHtmlTemplateContent , myMapWithValues );
如果我们有办法使用 thymeleaf 解决问题或者是否可以使用 thymeleaf 模板引擎,将会很有帮助。
【问题讨论】:
标签: java spring spring-boot thymeleaf template-engine