1. Freemarker Gets the size of the list:
Java
Java code
- arraylist<string> list = new arraylist<string> ();
Freemaker
JavaScript code
- ${list?size}
2. List traversal:
JavaScript code
- < #list animals as being>
- <tr>
- <td>${being.name}${being.price}<td>
- </tr>
- </#list >
The subscript number in the 3.list traversal:
_index is a property of list
JavaScript code
- < #list list as a>
- ${a_index}
- </#list >
4. Nesting of list:
JavaScript code
- < #list jssklist as jsskvo>
- < #list kclist as kcvo>
- <#if kcvo.kch=jsskvo.kch> (KCVO with number and name, and JSSKVO only number)
- ${KCVO.KCM}
- </#if>
- </#list >
- </#list >
5. List sort:
Ascending. Sort_by ()
JavaScript code
- < #list list?sort_by ("field") as X>
- </#list >
Descending. Sort_by ()? reverse
JavaScript code
- < #list list?sort_by ("field")? reverse as X>
- </#list >
6. The list tag traverses the map:
JavaScript code
- < #list Avertisementtypemap?keys as key>
- <option value="${key}" >${avertisementTypeMap[key]}</option>
- </#list >
http://lauy.iteye.com/blog/1774917
Freemarker list (length, traversal, subscript, nesting, sort)