My problem is the following :
I\'ve 2 differents objects that I\'ve to fill from a single form.
With 1 object, I simply do in the newFoo.html:
i used a div tag to surround the form input for my second object and added a th:object..... the controller processed it and added it to the database.
<form method=post th:object="${object1}" >
<div th:object="${object2}" >
code......
</div>
<input type="submit" />
</form>
I don't think you need to use two th:objects
. Just use th:value
<form th:action="@{/foo}" method="post">
<input type="text" th:value="${foo.name}" name="name"/>
<input type="text" th:value="${bar.status}" name="status"/>
<button type="submit">Go</button>
</form>
I would think Spring is smart enough, on the controller side, to use its mapping techniques to map your fields to their proper command object, foo or bar.