对象上的Thymeleaf调用方法

per*_*son 3 html-table thymeleaf

是否可以在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>
Run Code Online (Sandbox Code Playgroud)

这会导致异常:

Exception evaluating SpringEL expression: "column.value(row)"
Run Code Online (Sandbox Code Playgroud)

是否有可能在Thymeleaf中执行此操作,例如将变量传递给其他变量的方法?

per*_*son 12

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

<table>
    <tr th:each="row : ${table.rows}">
        <td th:each="column : ${table.columns}">
            <span th:text="${column.getValue(row)}"/>
        </td>
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)