栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何在Spring Boot应用程序中使用Thymeleaf加载HashMap和ModelandView对象值?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何在Spring Boot应用程序中使用Thymeleaf加载HashMap和ModelandView对象值?

请尝试以下解决方案之一。

解决方案1:

<table>        <tr th:each="element : ${parameters}">   <td th:text="${element.key}">keyvalue</td>         <table>  <tr th:each="elementSingle : ${element.value}">      <td th:text="${elementSingle.name}">Some name</td>      <td th:text="${elementSingle.description}">Description</td>  </tr>         </table>        </tr>    </table>

解决方案2:

<table >  <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>

解决方案3:

<tr th:each="instance : ${parameters}">  <td th:text="${instance.key}">keyvalue</td>  <td th:text="${instance.value.fieldName}">num</td></tr>

注意:根据您的代码设置变量。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/369451.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号