kotlin - Thymeleaf:一个简单的 for 循环中的“异常评估 OGNL 表达式”
问题描述
我有这个控制器:
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 调试模式?有没有办法打印模型树?我不知道为什么表达是错误的。
解决方案
尝试更改votes-positive
为不使用连字符的内容。这被解释为 OGNL 减法表达式中的减号。
推荐阅读
- java - RESTful Web 服务客户端 - 传递对象或仅传递对象的 id
- c++ - 尝试获取函数地址时出现错误 127
- wrapper - VEP 蛇形包装器的问题
- uitableview - Swift cellforrow 异步加载
- powershell - 捕获两个不同字符之间的文本。在第一个{和最后一个}之间
- python - MacOS 仍然指向 python3.6
- python - 如何在 csv 列中查找重复项,并删除任何没有重复项的行
- php - 运行 SQL 查询时可以使用 php echo 吗?
- python - 基于其他数据帧删除数据帧的行
- powershell - Powershell选择值之间