Java thymeleaf th:每个都不循环

Java thymeleaf th:每个都不循环,java,spring-mvc,thymeleaf,Java,Spring Mvc,Thymeleaf,我的网站从数据库中读取数据并显示在表中,但没有按应有的方式工作。 我的控制器 public String printWelcome(ModelMap model) { model.addAttribute("message", "Hello world!"); List<User> users = userDAO.getAllUser(); model.addAttribute("users", users); return "hello"; } 公

我的网站从数据库中读取数据并显示在表中,但没有按应有的方式工作。
我的控制器

public String printWelcome(ModelMap model) {
    model.addAttribute("message", "Hello world!");
    List<User> users = userDAO.getAllUser();
    model.addAttribute("users", users);
    return "hello";
}
公共字符串printWelcome(ModelMap模型){
addAttribute(“message”,“helloworld!”);
List users=userDAO.getAllUser();
model.addAttribute(“用户”,用户);
回复“你好”;
}
我的看法

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<body>
    <h1>${message}</h1>
    <h1>${users.get(0).username}</h1>
    <h1>${users.get(1).passw}</h1>
    <table>
        <thead>
        <tr>
            <th>name</th>
            <th>password</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="user : ${users}">
            <td th:text="${user.username}"/>
            <td th:text="${user.passw}"/>
        </tr>
        </tbody>
    </table>
</body>
</html>  

${message}
${users.get(0.username}
${users.get(1.passw}
名称
密码
“你好”一词出现了。还列出了第一个数据的用户名和第二个数据的密码的内容也显示良好。但是包含循环数据的表不会显示,而是在html代码上显示对象


在项目中配置Thymeleaf时遇到问题,源文件中的“th”标记在解析后应转换为HTML,但生成的HTML仍显示原始标记


检查

如果在项目中配置Thymeleaf时遇到问题,则源文件中的“th”标记应在解析后转换为HTML,但生成的HTML仍显示原始标记


按照Sotirios Delimanolis关于弹簧配置的要求,检查。我试图找出并发现该文件是mvc-dispatcher-servlet.xml。而且它与java版本是冗余的


我的解决方案,删除xml部分。

正如Sotirios Delimanolis所问的关于spring配置的问题。我试图找出并发现该文件是mvc-dispatcher-servlet.xml。而且它与java版本是冗余的


我的解决方案,删除xml部分。

您确定这是一个thymeleaf视图吗?请向我们展示您的Spring MVC配置。您是指pom.xml中的代码吗?org.thymeleaf-thymeleaf-spring4 2.1.4.RELEASE否我指的是您的Spring配置。我真的很抱歉,我对这件事还是很熟悉。你能告诉我哪个文件和它是什么样子的吗?你确定那是thymeleaf视图吗?请向我们展示您的Spring MVC配置。您是指pom.xml中的代码吗?org.thymeleaf-thymeleaf-spring4 2.1.4.RELEASE否我指的是您的Spring配置。我真的很抱歉,我对这件事还是很熟悉。你能告诉我哪个文件是什么样子的吗。
<tr th:each="user : [com.pckg.model.User@414e9cef, com.pckg.model.User@72d57b3c, com.pckg.model.User@2640e7f3, com.pckg.model.User@35ef8cf9, com.pckg.model.User@f3c74f, com.pckg.model.User@592640f6, com.pckg.model.User@78f84b5e, com.pckg.model.User@313998fc]">
    <td th:text=""></td>
    <td th:text=""></td>
</tr>