小编Jus*_*Fun的帖子

如何在Thymeleaf中显示每个循环的对象集合?

我想用Spring MVC在浏览器中显示数据库中的数据.一切都没问题,除了每个循环的Thymeleaf模板.那里出了点问题.

如何idID行中显示数据,nameName行中显示数据,迭代每个循环的对象集合?

源代码:

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
     <title>Getting Started: Serving Web Content</title>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
    <table border="1">
        <tr style="font-size: 13">
            <td>ID</td>
            <td>Name</td>
        </tr>
        <tr th:each="count :  ${id}">
            <td><p th:text="${count}" /></td>       
            <td><p th:text="${name}" /></td>        

        </tr>
    </table>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

java spring-mvc thymeleaf

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

java ×1

spring-mvc ×1

thymeleaf ×1