java thymeleaf,将模型属性绑定到多个表单元素
我有一个模型属性(区域),可以绑定到多个表单元素,如下所示:
<select th:field="*{region}" class="custom-select" id="country" style="padding: 0px">
<option value="a" selected>Select one..</i></option>
<option th:each="country : ${counties}" th:value="${country.id}" th:text="${country.name}"
selected></option>
</select>
<select th:field="*{region}" class="custom-select" id="state" style="padding: 0px">
<option value="a" selected>Select one..</i></option>
<option th:each="state : ${states}" th:value="${state.id}" th:text="${state.name}"
selected></option>
</select>
如图所示,模型的region属性可以绑定到国家或州,我有一个无线组供用户选择其中一个。我的问题是如何确定要传递给控制器以保存的文件。有没有一种方法可以动态地为模型设置th:字段,或者有其他可行的解决方案
共 (0) 个答案