首页 > 其他分享 >freemarker处理list的内置函数

freemarker处理list的内置函数

时间:2023-04-07 10:24:57浏览次数:32  
标签:内置 freemarker chunk list paymentPlugin 列表 content nbsp

freemarker处理list的内置函数

  1. first 没有括号
  2. last 没有括号
  3. seq_contains
  4. seq_index_of
  5. size 没有括号
  6. reverse
  7. sort
  8. sort_by 如果list中放置的是对象的话,可以根据某个属性来排序
  9. chunk 将list分块
<#assign listVar = [1,2,3,4,5,6,7,8,9,0,1,2]/>
<#list listVar?chunk(4)?last as item>
    ${item}
</#list>
//chunk(4)的意思是,从列表中顺序的一次取4个元素,取出来组成一个列表
//上面的例子
//第一个列表是:[1,2,3,4] 4个元素
//第二个列表是:[5,6,7,8] 4个元素
//第三个列表是:[9,0,1,2] 4个元素
//新列表:[[1,2,3,4],[5,6,7,8],[9,0,1,2]]

例如
[#list paymentPlugins?chunk(5, "") as row]
                                        <tr>
                                            [#list row as paymentPlugin]
                                                [#if paymentPlugin?has_content]
                                                    [#if paymentPlugin.id == 'weixinNativePaymentPlugin']
                                                        <td>
                                                            <input type="radio" id="${paymentPlugin.id}" name="paymentPluginId" value="${paymentPlugin.id}"[#if paymentPlugin == defaultPaymentPlugin] checked="checked"[/#if] />
                                                            <label for="${paymentPlugin.id}">
                                                                [#if paymentPlugin.logo?has_content]
                                                                    <em title="${paymentPlugin.paymentName}" style="background-image: url(${paymentPlugin.logo});">&nbsp;</em>
                                                                [#else]
                                                                    <em>${paymentPlugin.paymentName}</em>
                                                                [/#if]
                                                            </label>
                                                        </td>
                                                    [#elseif paymentPlugin.id == 'alipayDirectPaymentPlugin']
                                                        <td>
                                                            <input type="radio" id="${paymentPlugin.id}" name="paymentPluginId" value="${paymentPlugin.id}"[#if paymentPlugin == defaultPaymentPlugin] checked="checked"[/#if] />
                                                            <label for="${paymentPlugin.id}">
                                                                [#if paymentPlugin.logo?has_content]
                                                                    <em title="${paymentPlugin.paymentName}" style="background-image: url(${paymentPlugin.logo});">&nbsp;</em>
                                                                [#else]
                                                                    <em>${paymentPlugin.paymentName}</em>
                                                                [/#if]
                                                            </label>
                                                        </td>
                                                    [/#if]

                                                [#else]
                                                    <td>
                                                        &nbsp;
                                                    </td>
                                                [/#if]
                                            [/#list]
                                        </tr>
                                    [/#list]

 

标签:内置,freemarker,chunk,list,paymentPlugin,列表,content,nbsp
From: https://www.cnblogs.com/webSnow/p/17295132.html

相关文章

  • 带删除按钮的ListView
    不用说了,上图先:importjava.util.ArrayList;importcom.ql.adapter.DeletableAdapter;importandroid.app.Activity;importandroid.os.Bundle;importandroid.view.View;importandroid.view.View.OnClickListener;importandroid.widget.Button;impo......
  • Lazy延时加载的ListView
    使用的是第三方开发包CWAC-AdapterWrapper.jarpackagecom.ql.app;/***Copyright(c)2008-2009CommonsWare,LLCLicensedundertheApacheLicense,Version2.0(the"License");youmaynotusethisfileexceptincompliancewiththeLi......
  • org.springframework.amqp.rabbit.listener.BlockingQueueConsumer$DeclarationExcept
    错误信息:com.xubo.rabbitmq.springbootrabbitmq.SpringbootRabbitmqApplication._________/\\/___'_____(_)______\\\\(()\___|'_|'_||'_\/_`|\\\\\\/___)||_)||||......
  • SwipeRefreshLayout和ListView的EmptyView共存冲突的问题
    SwipeRefreshLayout是android官方的下拉刷新控件;它内部有且只能有一个子控件;当一个ListView嵌入到它内部时,就不能为ListView带一个EmptyView了;于是很自然的想到将ListView和EmptyView纳入到一个父控件中;典型的像下面这样的布局:<android.support.v4.......
  • LoadMoreListView+SwipeRefreshLayout(分页下拉)基本结构
    一切为了快速迭代importjava.util.ArrayList;importorg.json.JSONObject;importandroid.animation.ObjectAnimator;importandroid.os.Bundle;importandroid.support.v4.widget.SwipeRefreshLayout;importandroid.util.Log;importandroid.vie......
  • 简单实现可以多选的ProductListDialog<T>
    只是一个范例,是为了代码快速迭代而写的使用了listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);效果图importjava.util.ArrayList;importjava.util.List;importandroid.app.Dialog;importandroid.content.Context;importandroid.os.Bundle......
  • 基于上一篇实现的SimpleListPopupWindow<T>
    这次是个简单的PopupWindow,快速迭代用。importjava.util.List;importandroid.content.Context;importandroid.view.View;importandroid.widget.AdapterView;importandroid.widget.LinearLayout.LayoutParams;importandroid.widget.ListView;im......
  • Page 对象与 list 对象的相互转换
    转载:Page对象与list对象的相互转换_page转list_ajungejava的博客-CSDN博客我们有的时候会用到分页,使用page对象,但是在处理逻辑中常常需要list对象和page对象的转换Page-->Listpage.getcontent();返回的是list<object>List-->PagenewpageImpl(List<Object>co......
  • 关于ListView中使用GestureDetector冲突的解决办法
    在做OnGestureListener手势滑动界面的时候,会遇到这样的问题,就是当界面中含有ListView的时候,OnGestureListener的界面滑动就被ListView拦截并消费掉了。为了解决这个问题需要重写ListView的OnTouchListener接口:ListViewlistView=(ListView)findViewById(R......
  • 上拉下拉刷新,支持ListView,GridView,ScrollView
    开源项目PullToRefresh详解(一)——PullToRefreshListView类似Lollipop滚动溢出效果的下拉刷新布局:JellyRefreshLayouthttp://www.open-open.com/lib/view/open1437223823115.html网上很多这样的效果都是继承某个具体的AdapterView或ScrollView,这样很不通......