0
我有一個嵌套對象,我將它用作表單的模型。Thymeleaf,Spring嵌套後臺對象不綁定表單上的值提交
public AgeBracketSet implements Serializable{
private String id;
private List<AgeBracket> ageBrackets;
/* Getters and Setters */
}
我已成功綁定該對象的形式的所有屬性,並且當視圖狀態呈現我可以可視化它們的值。這裏是我用Thymeleaf做的一個簡化版本。本質上,我遍歷列表中的項目並獲取它們的屬性。
<form id="bracketForm" role="form" th:action="${flowExecutionUrl}" th:object="${ageBracketSet}" method="post">
<input th:id="'bracketSet_'+*{id}" th:field="*{id}" />
<th:block th:each="bracket,loop : *{ageBrackets}" th:id="'bracket_'+${bracket.id}">
<input th:id="'fromAge_'+${bracket.id}" th:field="*{ageBrackets[__${loop.index}__].fromAge}" />
<input th:id="'toAge_'+${bracket.id}" th:field="*{ageBrackets[__${loop.index}__].toAge}" />
</th:block>
</form>
但是,當我在表單中進行更改並提交時,模型保持不變。我通過調試接收表單數據的服務來確認這一點。該模型沒有在表單中進行更改。我在這裏做錯了什麼?