简体   繁体   中英

How to access object in thymeleaf block?

I'm showing a table content as follows. Note especially how *{id} maps automatically to the row content:

<table>
    <tbody>
    <th:block th:each="row : ${content}">
        <tr th:object="${row}">
            <td th:text="*{id}/>
            <td th:text="${#temporals.format(row.thedate, 'yyyy-MM-dd HH:mm:ss')}">
                2017-08-07 20:01:52
            </td>
        </tr>
    </th:block>
    </tbody>
</table>

Question: how can I rewrite the #temporals expression to also use implicit reference to the row? Eg, the following does not work:

<td th:text="${#temporals.format(*{thedate}, 'yyyy-MM-dd HH:mm:ss')}">

Why is *{thedate} expression not working here?

It's

<td th:text="*{#temporals.format(thedate, 'yyyy-MM-dd HH:mm:ss')}">

See the example in the thymeleaf docs: http://www.thymeleaf.org/doc/tutorials/3.0/usingthymeleaf.html#order-details

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM