小编che*_*roz的帖子

如何使用 thymeleaf 迭代二维数组

我有一个数独生成器类,它以双数组 (int) 的形式返回 9x9 数独板,我试图循环遍历该数组并创建一个表,但我陷入困境,在 Thymeleaf 网站上找不到任何信息。

更新

感谢@Nikolas,让它工作了

<form  id="sudokuBoard" method="post">
        <table class="table table-dark">
            <tr th:each="row: ${board}">
                <td th:each="value: ${row}">
                    <div th:switch="${value}">
                        <input th:case="0" style="width:30px;height:30px;text-align:center" type = "text" maxlength="1" value="0">
                        <input th:case="*" style="width:30px;height:30px;text-align:center;background-color:lightgreen" type = "text" th:value="${value}" readonly>
                    </div>
                </td>
            </tr>
        </table>

        <input type="submit"> Check Solution </input>
    </form>
Run Code Online (Sandbox Code Playgroud)

java spring thymeleaf

2
推荐指数
1
解决办法
2162
查看次数

标签 统计

java ×1

spring ×1

thymeleaf ×1