Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/GoSaint/article/details/89491017
Controller layer as follows:
@RequestMapping(value = "/test", method = RequestMethod.GET)
public String test(Model model) {
List<City> cityList = cityService.findAllCity();
model.addAttribute("cityList",cityList);
return "test";
}
reemaker follows:
<table border="1">
<tr>
<td>城市名</td>
<td>省编码</td>
<td>描述</td>
</tr>
<#list cityList! as city>
<tr>
<td>${city.cityName!}</td>
<td>${city.provinceId!}</td>
<td>${city.description!}<br></td>
</tr>
</#list>
</table>
Note: freemaker added behind the object! It indicates allowing the object is empty. You may not add! Direct write object.
Results are as follows: