spring - 为什么不工作
问题描述
我正在尝试遍历包含对象列表的列表,即 List 我想知道为什么这不起作用,尝试简单地使用“i”,但没有运气。
List<Object[]> lists; // logic
model.addObject("lists", lists);
model.addObject("table_width", lists.get(0).length);
Thymeleaf 代码片段
<table class="table table-responsive table-stripped table-collapsed table-bordered">
<tr th:each="rows,rowStat : ${lists}">
<td th:text="${rowStat.count}"></td>
<td th:each="i : ${#numbers.sequence(0, table_width)}" th:text="${rows[${i}]}"></td>
</tr>
</table>
解决方案
我找到了一个方法,
<td th:each="i : ${#numbers.sequence(0, table_width-1)}" th:text="${rows[__${i}__]}"></td>
这是诀窍
推荐阅读
- python - 列表理解/生成器表达式中的“x in y”的对立面是什么?
- ag-grid - ag-Grid 中 cellStyle 和 rowStyle 的样式冲突
- python - PyInstaller:无法为未注册的加载程序类型执行此操作
- laravel - Laravel 碳日期添加 7 分钟
- php - PHP Spreadsheet / Laravel Excel - CSV 中的日期格式在编辑后转换为用户本地格式
- mule - 访问变量中的属性 json (flowVars) Mulesoft
- wcf - 如何手动创建 wcf 服务故障异常?
- java - 无法解析查询 - 在 graphql.GraphQL.execute()
- javascript - iOS 移动浏览器上的切换选项卡无法通过 href 目标甚至 window.open 窗口焦点工作
- bash - 多个whois查询