FreeMarker grammer
The following code snippet shows how to get the values of a Map (e.g. HashMap) from within a Freemarker template.
<#assign m = myMap>
<#assign values = m?values>
<
ul
>
<#list values as myObject>
<
li
>${myObject.myPropery}</
li
>
</#list>
</
ul
>
You can do a similar thing with the keys of a map as shown below.
<#assign m = myMap>
<#assign keys = m?keys>
<
ul
>
<#list keys as key>
<
li
>${key}</
li
>
</#list>
</
ul
>
<#foreach friendId in entry.commonFriends>
//friendId 是int类型
<#if results.commonFriendsProfileMap[friendId?string]??>
//friendId?string 将int转为string类型,commonFriendsProfileMap的value值为一个对象
${results.commonFriendsProfileMap[friendId?string].name}
${results.commonFriendsProfileMap[friendId?string].photoUrl}
</#if>
</#foreach>
<#assign pageStart=results.listPageStart>
<#assign pageEnd=results.listPageEnd>
<#list pageStart..pageEnd as index>
<#if results.currentPage == index>
${index}
</#if>
</#if>
</#list>
<#list entry.object.skills as skill>
<#if skill_index < 3 >
//list里是对象,只在list里取三个
${skill.skill_name} |${skill.skill_level}
</#if>
</#list>
<#if entry.count > 1000>
<#elseif entry.count ==2>
<#else>
</#if>