Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在thymeleaf中显示对象_Java_Spring_Spring Mvc_Thymeleaf - Fatal编程技术网

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>

洋葱