html,thymeleaf模板动态表格var cqzzs = [[${xqdXqdzb.cqzzs}]]; var cqzys = [[${xqdXqdzb.cqzys}]]; var shuzi=cqzzs+cqzys; var mergedRow = document.getElementById("merged-row");if (shuzi > 0) { td_tag = "<td rowspan='shuzi'>派出检查员姓名</td><td colspan='8'></td><td>检查组中职务</td><td>□组长 □组员 □观察员 □_____</td><td rowspan='shuzi' >选取形式</td><td >□随机 □指定</td>"; td_tag = td_tag.replace(/'shuzi'/g, shuzi); mergedRow.innerHTML = td_tag; } for (var i = 1; i <shuzi; i++) { var newRow = document.createElement("tr"); newRow.innerHTML = "<td colspan='8'></td><td>检查组中职务</td><td>□组长 □组员 □观察员 □_____</td><td >□随机 □指定</td>"; // 根据表格的列数设置 mergedRow.parentNode.insertBefore(newRow, mergedRow.nextSibling); } 如何正确显示从后台传的List<XqdXqdJcy> xqdJcyList=xqdJcyService.selectXqdXqdJcyByXqdid(xqdid); mmap.put("xqdJcyList",xqdJcyList);的值,
时间: 2023-09-23 08:03:34 浏览: 48
你可以使用Thymeleaf模板引擎中的th:each指令来遍历xqdJcyList并在表格中显示每个元素的属性值。以下是一个示例:
```
<table>
<thead>
<tr>
<th>派出检查员姓名</th>
<th colspan="8"></th>
<th>检查组中职务</th>
<th>□组长 □组员 □观察员 □_____</th>
<th rowspan="[[${xqdJcyList.size()}]]">选取形式</th>
<th>□随机 □指定</th>
</tr>
</thead>
<tbody>
<tr th:each="jcy : ${xqdJcyList}">
<td th:text="${jcy.name}"></td>
<td colspan="8"></td>
<td>检查组中职务</td>
<td>□组长 □组员 □观察员 □_____</td>
<td>□随机 □指定</td>
</tr>
</tbody>
</table>
```
在上面的示例中,使用了Thymeleaf的th:each指令来遍历xqdJcyList,并为每个元素创建一个新的表格行。在每个表格单元格中,使用th:text指令将元素的属性值绑定到单元格中。注意,使用Thymeleaf表达式[[${...}]]来计算表格行的rowspan属性值。
相关问题
html thymeleaf模板 <td colspan="3">起始[[${xqdXqdzb.jcjssj}]]~结束[[${xqdXqdzb.jcjssj}"]]</td>格式化日期为yyyy年MM月dd日格式
可以使用 Thymeleaf 的日期格式化语法来实现:
```
<td colspan="3">起始[[(#dates.format(xqdXqdzb.jcqssj, 'yyyy年MM月dd日'))]]~结束[[(#dates.format(xqdXqdzb.jcjssj, 'yyyy年MM月dd日'))]]</td>
```
其中 `#dates.format` 表示对日期进行格式化,第一个参数是要格式化的日期对象,第二个参数是目标格式。这里使用的是 `yyyy年MM月dd日` 格式。
spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html spring.thymeleaf.cache=false spring.thymeleaf.mode=LEGACYHTML5
As an AI language model, I do not have access to the context of your question. However, I can provide you with a general explanation of the code snippet you provided.
The code snippet is configuring the Thymeleaf template engine for a Spring Boot application. Thymeleaf is a popular Java template engine for building web applications.
The first line sets the prefix for the Thymeleaf templates, which is the directory where the templates are located. In this case, it is set to "classpath:/templates/". This means that the templates are located in the "templates" directory in the classpath.
The second line sets the suffix for the Thymeleaf templates, which is the file extension for the templates. In this case, it is set to ".html".
The third line sets the caching option for the Thymeleaf templates. In this case, it is set to "false", which means that the templates are not cached.
The fourth line sets the mode for the Thymeleaf templates. In this case, it is set to "LEGACYHTML5", which means that the templates are parsed using the legacy HTML5 parsing rules.