java - 如何在 thymeleaf 中将对象 id 设置为 div id?

标签 java html thymeleaf

我正在尝试将我的对象 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/

相关文章:

html - table 不会达到 100% 高度

java - 在 Tomcat 7 上部署 War 错误

javascript - 如何在 Thymeleaf 中将 javascript 文件内容嵌入到 html 页面中?

java - 当我刷新包含数据表的页面时,我丢失了添加的新数据 Primefaces JSF

java - 为 Guava Cache 选择键

html - 如何在同一个组件中定义两个管道

javascript - 如何将输入值数组发送到 Controller

java - 如何使用子类对象访问隐藏的父类(super class)成员

java - 从Java执行sh文件

javascript - 当我搜索我的网站并按 Enter 键时,搜索会正确执行,但按按钮时,搜索结果不会