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

上一篇:The Parallel Challenge Ballgame[HDU1101]


下一篇:城市平乱(Bellman)