我正在尝试将我的对象 ID 设置为 div id,但是当我尝试运行我的应用程序时,我收到错误消息
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing
堆栈跟踪中的另一个错误:
org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'id' cannot be found on object of type 'io.getstream.core.models.EnrichedActivity' - maybe not public or not valid?
这是我的 html 代码:
<div typeIdFieldName="id" th:id="${#strings.trim(object['id'])}" class="c-default-item" th:each="object : ${objects}"></div>
最佳答案
您正在寻找
th:id="${object.id}"
假设由 th:each="object : ${objects}"
迭代的列表中的每个对象都包含一个“id”属性,它的 getter 形式为 getId (){...}
,模型有一个称为“对象”的对象列表。
关于java - 如何在 thymeleaf 中将对象 id 设置为 div id?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58059071/