在我的系统中,我需要在 html 表中使用 java for 循环来打印 8.00-17.00 的时间。有人可以解释我怎么做吗?谢谢。
html文件
<!DOCTYPE html>
<html xmlns:th="https://www.thymeleaf.org">
<head>
<link rel="stylesheet" type="text/css" href="static/css/timeTable.css" th:href="@{/css/timeTable.css}">
<meta charset="UTF-8">
<title>Time Table</title>
</head>
<body>
<div class="container" style="margin-top:30px">
<br><br>
<table border="1" class="table2">
<thead>
<tr>
</tr>
<br>
<tr>
<td></td>
<th>Monday</th>
<th>Tuesday</th>
<th>Wednesday</th>
<th>Thursday</th>
<th>Friday</th>
</tr>
</thead>
<tbody>
<tr>
<% for(int i=0;i<17;i++){
<td> i.":00 - ".($i+1).":00" </td>
}
</tr>
</tbody>
</table>
</div>
</body>
</html>
我能够通过使用以下方式来做到这一点。感谢所有试图提供帮助的人
<option th:each="i : ${#numbers.sequence( 8, 17)}">
<tr>
<th th:text="${ i }+':00 - ' + ${ i+1 }+':00'"></th>
</tr>
</option>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句