首页 > 解决方案 > Thymeleaf th:value 在使用 th:field 时被忽略

问题描述

我有一个表单,可以在其中遍历 class 的项目列表Runway。我正在尝试将初始值设置为th:value = "${rwy.getDir1()}"并将输入连接到另一个对象th:field = "*{messageList[__${mStat.index}__].runway}",但th:value忽略了。

<div th:each="rwy, mStat: ${runways}">
    <label>Runway</label>
        <input type="text" class="text-input-small" th:field = "*{messageList[__${mStat.index}__].runway}" th:value = "${rwy.getDir1()}" th:id="'runway' + ${mStat.index}" th:name = "runway">
</div>
                

如何将字段映射到messageList并使用 设置初始值th:value = "${rwy.getDir1()}"

标签: javaspring-bootthymeleaf

解决方案


推荐阅读