3. 编写循环来遍历list<map> 在FreeMarker 模板中,可以使用 <#list> 指令来遍历列表。对于 list<map> 结构,可以首先遍历列表,然后在内部遍历每个 map。 示例FreeMarker 模板代码: freemarker <#list dataList as item> <p> Name: ${item.name}<br> Age: ${...
public static void test_list(){ Map<String,Object> map = new HashMap<String,Object>(); FreemarkerUtil fu = new FreemarkerUtil(); Session session = null; Transaction trans = null; try{ session = HibernateUtil.getCurrentSession(); trans = session.getTransaction(); trans.begin(); List<Prod...
List list=ClientTest.initUserList(); Map root=new HashMap(); root.put(“userList”,list); FreeMarkertUtil.analysisTemplate(“user.ftl”,”UTF-8”,root); //FreeMarkUtil类可以参考我上传得源码。 } } 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19...
Map map1 = new HashMap();map1.put("phone", "13655555555");map1.put("email", "admin@vip.com");map1.put("address", "china");list.add(map1);Map map2 = new HashMap();map2.put("phone", "13888888888");map2.put("email", "china@vip.com");map2.put("address", "...
<#if (result.data.list)?exists> <#assign list= result.data.list> <#assign keys = list?keys> <#assign length = keys?size> <#list keys as key> <#if key_index == 0> ...需要显示的html </#if> </#list> </#if> freemarker取list的最后一个元素 循环用法 <#...