【发布时间】:2017-05-02 11:33:34
【问题描述】:
我错过了大约 30 分钟试图弄清楚如何从我的电子邮件服务生成 HTML 正文。这是一个计划任务,而不是 API 调用 - 意味着没有控制器或 MVC 应用程序逻辑。只需处理模板。
我有原始 java,我想用 Thymeleaf 处理单个 *.html 文件。该怎么做?
换句话说,我需要 Thymeleaf 类比 Velocity 示例:
VelocityEngine ve = new VelocityEngine();
ve.init();
Template t = ve.getTemplate( "helloworld.vm" );
VelocityContext context = new VelocityContext();
context.put("name", "World");
StringWriter writer = new StringWriter();
t.merge( context, writer );
附:我已阅读 this 问题,它没有提供答案。 Thymeleaf doc 和 thymeleafexamples-gtvg 都绑定到控制器逻辑、解析器和其他我不需要的东西。
【问题讨论】:
-
看来我在这里得到了答案github.com/thymeleaf/thymeleaf/issues/561
标签: java thymeleaf template-engine