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