freemarker中遍歷list >


<#list var as map>
<tr>
 <#list map?keys as itemKey> //關鍵點
    <#if itemKey="fieldLabel" && map['type'] == "text" >
     <td >${map[itemKey]}</td>
    </#if>
    <#if itemKey="java_lang_String" && map['type'] == "text">
         <td >${map[itemKey]}</td>
    </#if>
   
   <#if itemKey="fieldLabel" &&  map['type'] == "file">
     <td  >${map['fieldLabel']}</td>
   </#if>
    <#if itemKey="java_io_file" && map['type'] == "file">
        <td >
      <#list "${map[itemKey]}"?split(",") as x>  //使用split函數,等同於java中的split函數
        <a href="FlowDownServlet?fileName=${x}">${x}</a>
      </#list>
    </td>
    </#if>
    </#list>
  <#if  map['type'] == "select">
   <td  >${map['fieldLabel']}</td>
   <td >
   <#list form.fields as field>
    <#if field.fieldInput.type == "select">
     <select name="props['${field.fieldName}']">
   <#list field.items as item>
     <option <#if map['java_lang_String'] == item.value>selected</#if> value="${item.value}">${item.label}</option>
   </#list>
    </select>
   </#if>
  </#list>
  </td> 
  </#if>
  
</tr>

</#list>

 

后台傳遞過來的數據

List<LinkedHashMap<String,Object>> var = SubmitManager.getInstance().getProperty(documentId);
rootMap.put("var", var);
template.process(rootMap, out);

 

原文出處http://blog.csdn.net/lsh6688/article/details/17091277


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM