【发布时间】:2018-06-26 12:30:36
【问题描述】:
final Context ctx = new Context();
context.setVariable("data", data);
templateEngine.process(template, context).trim();
这里是进口:
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
模板变量指向“content_completed”。其中这个 content_completed 是一个存在于项目类路径中的 html 文件。
这个html文件的内容:
<html xmlns:th="http://www.thymeleaf.org" th:inline="text" th:remove="tag">
[[${data.fileName}]][[${T(abc.composer.NoteData).COMPLETED_NO_ERRORS}]]
</html>
NoteData 是一个 java 类
如果这个 data.fileName 有类似“sample&.text”的内容,Thymeleaf 模板引擎会将其更改为“sample&.text”。
关于如何避免这种情况的任何想法?
【问题讨论】:
标签: java thymeleaf template-engine