Java 如何在thymeleaf中显示对象
我需要显示我从控制器得到的用户列表Java 如何在thymeleaf中显示对象,java,spring,spring-mvc,thymeleaf,Java,Spring,Spring Mvc,Thymeleaf,我需要显示我从控制器得到的用户列表 @GetMapping("/maintenance-user") public ModelAndView Index() throws Exception { ModelAndView model = new ModelAndView("maintenance/user/index"); model.addObject("model",service.get()); return model; } get返回一个Iterable对象
@GetMapping("/maintenance-user")
public ModelAndView Index() throws Exception
{
ModelAndView model = new ModelAndView("maintenance/user/index");
model.addObject("model",service.get());
return model;
}
get返回一个Iterable对象
这就是我的观点
<p th:text="${model.Id}"></p>
但它返回属性或在对象上找不到字段“Id”
我在这里遗漏了什么?您需要使用类似于下面的
th:each
来迭代列表
<tr th:each="obj : ${model}">
<td th:text="${obj.Id}">Onions</td>
</tr>
洋葱