freemarker遍历map

<#if bookMap?exists>
     <#list bookMap?keys as bookKey>
     <#if bookKey_index%2 = 0>
      <tr class="odd">
      <#else>
      <tr class="even">
      </#if>
     
     <#assign values = bookMap[bookKey]>
     <#if values?exists>
     <#if values["book"]?exists>
     <#assign book = values["book"]>
     <td>${book.isbn?default("")}</td>
     <td><a href="/book/show/${book.id?c}">${book.title?default("")}</a></td>
     <td>
     <#if values["authorList"]?exists>
     <#assign authors=values["authorList"]>
     <#if authors?exists>
     <#list authors as author>
     ${author.username?default("")}
     </#list>
     </#if>
     </#if>
     </td>
     <#if book.pubdate??><td>${book.pubdate?string("yyyy-MM-dd")}</td><#else><td>&nbsp;</td></#if>
     <td>${book.publisher?default("")}</td>
     </#if>
     </#if>
     </tr>
     </#list>
     </#if>

你可能感兴趣的:(freemarker)