html-table – 对象上的Thymeleaf调用方法

html-table – 对象上的Thymeleaf调用方法,第1张

概述是否可以在Thymeleaf的“每个”循环中调用对象方法?我正在尝试创建一个动态表,其中行和列都可以是动态的.表具有行列表和列列表.列有一个getValue方法,对于给定的Row,可以获取该值.但是我无法从Thymeleaf那里调用这个getValue(行行). 我有这个Thymeleaf代码: <table> <tr th:each="row : ${table.rows}"> 是否可以在Thymeleaf的“每个”循环中调用对象的方法?我正在尝试创建一个动态表,其中行和列都可以是动态的.表具有行列表和列列表.列有一个getValue方法,对于给定的Row,可以获取该值.但是我无法从Thymeleaf那里调用这个getValue(行行).

我有这个Thymeleaf代码:

<table>    <tr th:each="row : ${table.rows}">          <td th:each="column : ${table.columns}">               <span th:text="${column.value(row)}"/>          </td>    </tr></table>

这会导致异常:

Exception evaluating SpringEL Expression: "column.value(row)"

甚至可以在Thymeleaf这样做,例如将变量传递给其他变量的方法?

解决方法 我发现了这个问题,因为我向这个方法传递了一些东西,它不是一个getter方法所以我必须提供完整的方法名称:getValue不仅仅是值:

<table>    <tr th:each="row : ${table.rows}">        <td th:each="column : ${table.columns}">            <span th:text="${column.getValue(row)}"/>        </td>    </tr></table>
总结

以上是内存溢出为你收集整理的html-table – 对象上的Thymeleaf调用方法全部内容,希望文章能够帮你解决html-table – 对象上的Thymeleaf调用方法所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1048722.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存