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>