JAVA 代码
public ArrayList getData(){
ArrayList arrayList=new ArrayList();
HashMap map1=new HashMap();
map1.put("name","jack");
map1.put("age","12");
HashMap map2=new HashMap();
map2.put("name","ven");
map2.put("age","18");
arrayList.add(map1);
arrayList.add(map2);
return arrayList;
}
@RequestMapping(value = "page")
public String page(Model model){
model.addAttribute("list",getData());
return "test/success";
}
html代码:
<table border="1">
<tr th:each="m:${list}">
<td th:text="${m.name}"/>
<td th:text="${m.age}"/>
</tr>
</table>
结果: