我需要显示我从控制器获得的用户列表。
@GetMapping("/maintenance-user")
public ModelAndView Index() throws Exception
{
ModelAndView model = new ModelAndView("maintenance/user/index");
model.addObject("model",service.get());
return model;
}
service.get返回一个Iterable对象
这是我的观点
<p th:text="${model.Id}"></p>
但它返回属性或在对象上找不到字段'Id'。
我在这里想念什么?
答案 0 :(得分:0)
您需要使用类似于下面的th:each
来迭代列表
<tr th:each="obj : ${model}">
<td th:text="${obj.Id}">Onions</td>
</tr>