表中的FTL序列号

时间:2016-01-18 07:16:10

标签: html freemarker

如何在freemarker中显示序列号的列表索引,我有一个列表debitnotedetails以及如何在td中显示序列号。 freemarker中是否有任何方法

<#list debitNoteDetails as debitNote>
    <#if debitNote_index % 2 == 0>
        <tr style="font-size:12px;">
    <#else>
        <tr style="font-size:12px;height:10px;background-color: #ececec;">
    </#if>
            <td style="width:100px;height:20px;" cellpadding="5">${debitNoteDetails.index}</td>
        </tr>
</#list>

1 个答案:

答案 0 :(得分:0)

序列号是什么意思?您已经在那里使用debitNote_index,这是项目的从0开始的索引。无论如何,这里有简洁的方法(基于1的计数):

<#list debitNoteDetails as debitNote>
    <tr style="font-size:12px<#if debitNote?is_even_item>;height:10px;background-color: #ececec;</#if>">
        <td style="width:100px;height:20px;" cellpadding="5">${debitNote?counter}</td>
    </tr>
</#list>

请注意,上述内容需要FreeMarker 2.3.23。在早期版本中,您可以使用debitNote_index

相关问题