freemarker頁面判斷重複值不輸出
阿新 • • 發佈:2018-11-03
freemarker 介面 table 迴圈的時候判斷是否有重複值出現,如果有不輸出繼續下次迴圈,寫套餐明細用到;
<td > <#if (item.itemGroupAccounts?size >0)>
<#list item.itemGroupAccounts as account>
//如果迴圈下標是第一個給i賦值等於名稱
<#if account_index == 0>
<#assign i =account.accountName ><#if(account.dataSource=171)>
<div>${account.accountName!''}:
${account.amount!''}元</div>
<#else>
//如果名稱相等就把名稱賦值給i(賦不賦值都相等)
<#assign i =account.accountName >
<#else>
//不相等輸出名字,把名字賦值給i
<#assign i =account.accountName >
</#if>
<div>${account.name!''}
${account.qty!''}次*${account.unitPrice!''}元=${account.amount!''}元</div>
</#if>
</#list>
</#if>
<span onclick="editItems('${item.id}')">編輯明細</span>
</td><td>
<spanclass="modify-icon" onClick="editItem('${item.id!''}','${item.name!''}')"> </span>
<span class="delete-icon" onclick="remove(${item.id})"></span>
</td>
</tr>
</#list>
</#if>
C場景: 當然我在後臺已經按照名稱排好序列了;