HashMap 中列表的 Thymeleaf 格式 [英] Thymeleaf format for list within a HashMap
本文介绍了HashMap 中列表的 Thymeleaf 格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将包含值列表的模板放在哈希图中的键中,但是当我尝试将其放入模板时,如果它自己落入新行.
图片:Thymeleaf 部分代码:
<h1 class="text-center">Boards</h1><小时/><table class="table table-striped"><tr><th>董事会名称</th><th>投资者</th><th>保险丝制造商</th><th>保险丝编号.波兰人<th>保险丝特性</th><th>保险丝数量</th></tr><th:block th:each="item, iterStat : ${map}" varStatus="status"><tr><td th:text="${item.key.name}"></td><td th:text="${item.key.investor}"></td><tr th:each="fuse : ${item.value}"><td th:text="${fuse.fuse.manufacturer.name}"></td><td th:text="${fuse.fuse.type}"></td><td th:text="${fuse.fuse.characteristics}"></td><td th:text="${fuse.quantity}"></td></tr></tr></th:block>
解决方案
您正在<tr/>
中创建<tr/>
ss.查看 thymeleaf 生成的源代码应该会告诉您这一点.我猜你的 html 应该是这样的:
<tr><th>董事会名称</th><th>投资者</th><th>保险丝制造商</th><th>保险丝编号.波兰人<th>保险丝特性</th><th>保险丝数量</th></tr><th:block th:each="item: ${map}"><tr th:each="fuse: ${item.value}"><td th:text="${item.key.name}"/><td th:text="${item.key.investor}"/><td th:text="${fuse.fuse.manufacturer.name}"/><td th:text="${fuse.fuse.type}"/><td th:text="${fuse.fuse.characteristics}"/><td th:text="${fuse.quantity}"/></tr></th:block>
I'm trying to put template which has a list of values within a key in a hashmap, However when I try to put it into the template if falls over into new row by itself.
Picture: Thymeleaf part of code:
<div class="container">
<h1 class="text-center">Boards</h1>
<hr />
<table class="table table-striped">
<tr>
<th>Board Name</th>
<th>Investor</th>
<th>Fuse Manufacturer</th>
<th>Fuse Nr. Of Poles</th>
<th>Fuse Characteritics</th>
<th>Fuse Amount</th>
</tr>
<th:block th:each="item, iterStat : ${map}" varStatus="status">
<tr>
<td th:text="${item.key.name}"></td>
<td th:text="${item.key.investor}"></td>
<tr th:each="fuse : ${item.value}">
<td th:text="${fuse.fuse.manufacturer.name}"></td>
<td th:text="${fuse.fuse.type}"></td>
<td th:text="${fuse.fuse.characteristics}"></td>
<td th:text="${fuse.quantity}"></td>
</tr>
</tr>
</th:block>
</table>
</div>
解决方案
You're creating <tr />
s in your <tr />
s. Looking at the source generated by thymeleaf should tell you this. I would guess your html should look something like this:
<table class="table table-striped">
<tr>
<th>Board Name</th>
<th>Investor</th>
<th>Fuse Manufacturer</th>
<th>Fuse Nr. Of Poles</th>
<th>Fuse Characteritics</th>
<th>Fuse Amount</th>
</tr>
<th:block th:each="item: ${map}">
<tr th:each="fuse: ${item.value}">
<td th:text="${item.key.name}" />
<td th:text="${item.key.investor}" />
<td th:text="${fuse.fuse.manufacturer.name}" />
<td th:text="${fuse.fuse.type}" />
<td th:text="${fuse.fuse.characteristics}" />
<td th:text="${fuse.quantity}" />
</tr>
</th:block>
</table>
这篇关于HashMap 中列表的 Thymeleaf 格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文