且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用freemarker删除数组中的重复元素?

更新时间:2021-11-02 08:59:25

您可以使用***标记序列.可能效率不是很高,但是我已经使用它来对接近发票等的最大尺寸线进行分组.

You can use freemarker sequences. Probably not super efficient but I've used this to group close to max size lines on invoices and such.

<#assign seen_style = []>
<#list record.item?sort_by("custcol_stylesort")  as lineitem>
   <#assign groupId = lineitem.item>
   <#if seen_style?seq_contains(groupId)> <!-- no if body is intentional; skips seen style -->
   <#else>
     <#assign seen_style = seen_style + [groupId]>
     <p>Do something with ${groupId}</p>
   </#if>
</#list>