zoukankan      html  css  js  c++  java
  • freemarker list (长度,遍历,下标,嵌套,排序)

    1. freemarker获取list的size : 

    Java 
    Java代码  收藏代码
    1. ArrayList<String> list = new ArrayList<String>();  

    Freemaker 
    Javascript代码  收藏代码
    1. ${list?size}  


    2. list的遍历: 

    Javascript代码  收藏代码
    1. <#list animals as being>  
    2.     <tr>  
    3.         <td>${being.name}${being.price}<td>  
    4.     </tr>  
    5. </#list>  


    3.list遍历中的下标序号: 

    _index是list的一个属性 
    Javascript代码  收藏代码
    1. <#list list as a>  
    2.      ${a_index}  
    3. </#list>   


    4. list的嵌套: 
    Javascript代码  收藏代码
    1. <#list jsskList as jsskVO>  
    2.    <#list kcList as kcVO>  
    3.            <#if kcVO.kch=jsskVO.kch> (kcVO里有编号和名称,而jsskVO里只有编号)  
    4.                   ${kcVO.kcm}   
    5.            </#if>  
    6.    </#list>  
    7. </#list>  


    5. list排序: 
          升序 .sort_by() 
    Javascript代码  收藏代码
    1. <#list list?sort_by("字段") as x>  
    2. </#list>  


         降序 .sort_by()?reverse 
    Javascript代码  收藏代码
    1. <#list list?sort_by("字段")?reverse as x>   
    2. </#list>  


    6. list标签遍历map: 
    Javascript代码  收藏代码
    1. <#list avertisementTypeMap?keys as key>   
    2.     <option value="${key}">${avertisementTypeMap[key]}</option>   
    3. </#list>  
     
    http://lauy.iteye.com/blog/1774917
  • 相关阅读:
    B树,B+树比较
    Kafka、RabbitMQ、RocketMQ 全方位对比
    ElasticSearch 笔记
    AtomicReference实现单例模式
    Netty 核心组件笔记
    Netty Reactor 线程模型笔记
    urldecode和urlencode相互转换
    python字符格式问题SyntaxError: Non-UTF-8 code starting with 'xe4'
    百度文字识别获取access token
    Python中MD5加密
  • 原文地址:https://www.cnblogs.com/a757956132/p/4427827.html
Copyright © 2011-2022 走看看