我有这个控制器:
it.render(
"my-list.html",
mapOf(
"votes-positive" to repo.votesOf("x"),
)
)
//...
data class Vote(
val name: String,
val type: Type,
) {
enum class Type { POS, NEG }
}
我的模板文件"my-list.html
:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<body>
<div th:each="vote : ${votes-positive}">
<span th:text="${vote.name}"></span>
</div>
</body>
运行它时出现此错误,这让我发疯:
[qtp119358627-23] ERROR org.thymeleaf.TemplateEngine - [THYMELEAF][qtp119358627-23] Exception processing template "my-list.html": Exception evaluating OGNL expression: "vote.name" (template: "my-list.html" - line 21, col 15)
org.thymeleaf.exceptions.TemplateProcessingException: Exception evaluating OGNL expression: "vote.name" (template: "my-list.html" - line 21, col 15)
是否有 Thymleaf 调试模式?有没有办法打印模型树?我不知道为什么表达是错误的。