gpt4 book ai didi

html - 在 thymeleaf 中创建一个表

转载 作者:技术小花猫 更新时间:2023-10-29 12:39:16 28 4
gpt4 key购买 nike

我是 thymeleaf 的新手,我正在尝试使用数组和 each 循环制作一个简单的表格。

我的代码是这样的:

<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title>Smoke Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<table border="1" style="width:300px">
<tr>
<td>Test Name</td>
</tr>
<tr th:each="smokeTest : ${smokeTests}">
<td>
th:text="${smokeTest.name}">A Smoke Test'
</td>
</tr>
</table>
</body>
</html>

基本上我的问题是我不能以 <td> 运行循环在 <tr> 内秒。有什么方法可以让这段代码起作用吗?

最佳答案

你必须把 th:text 作为一个标签的属性,所以

<tr th:each="smokeTest : ${smokeTests}">
<td th:text="${smokeTest.name}">A Smoke Test'</td>
</tr>

应该运行。

关于html - 在 thymeleaf 中创建一个表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24614113/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com