Freemarker循环遍历
生活随笔
收集整理的這篇文章主要介紹了
Freemarker循环遍历
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
循環格式
<#list 要循環的數據 as 循環后的數據> </#list>循環的下標
通過,item_index獲取
比如
<#list studentList as student> ${student_index} </#list>數據集
//6.創建一個數據集,可以是pojo也可以是map,推薦使用map Map data = new HashMap<>(); List<Student> stuList = new ArrayList<>(); stuList.add(new Student(1, "小米", 11, "北京昌平回龍觀")); stuList.add(new Student(2, "小米2", 12, "北京昌平回龍觀")); stuList.add(new Student(3, "小米3", 13, "北京昌平回龍觀")); stuList.add(new Student(4, "小米4", 14, "北京昌平回龍觀")); stuList.add(new Student(5, "小米5", 15, "北京昌平回龍觀")); stuList.add(new Student(6, "小米6", 16, "北京昌平回龍觀")); stuList.add(new Student(7, "小米7", 17, "北京昌平回龍觀")); data.put("stuList", stuList);模板
<html> <head><title>測試頁面</title> </head> <body>學生列表:<br><table border="1"><tr><th>序號</th><th>學號</th><th>姓名</th><th>年齡</th><th>家庭住址</th></tr><#list stuList as stu><tr><td>${stu_index}</td><td>${stu.id}</td><td>${stu.name}</td><td>${stu.age}</td><td>${stu.address}</td></tr></#list></table> </body> </html> 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的Freemarker循环遍历的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Freemarker获取pojo属性
- 下一篇: Freemarker条件判断