Im getting list of Order and make table with it + button next to every Item.
On click button i want to post this single Order from list to API.
The problem is when i press button, i receive on API empty object of this item with parameters 0, null, "" etc...
@GetMapping
public String findAllOrders(Model model) {
model.addAttribute("orderlist", orderService.findAll());
return "index";
}
@PostMapping("/change")
public void setPayOrder(@ModelAttribute("order") Order order) {
System.out.println(order); <------ this order from sended list is empty
}
index
<table>
<thead>
<tr>
<th>Id</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr th:each="order:${orderlist}">
<td th:text="${order.idOrder}"></td>
<td th:text="${order.description}"></td>
<td>
<form th:method="POST" th:action="@{/change}" th:object="${order}">
<button type="submit">Change pay</button>
</form>
</td>
</tr>
</tbody>
</table>
So talking simple i need this:
GetListOfItemFromApi:
Item>button(Send this item to api)
Item>button(Send this item to api)
Item>button(Send this item to api)`
How can i send to api single Order from list?