I'm having trouble getting this to work. I'll keep my code and idea generic since I've seen a few examples of people with similar problems:
The basic idea is that the view has a list of order items with properties that the user can modify inside a form. When the user submits the form, I want the order items populated with the data that the user submitted.
How do I create the HTML form that populates this @ModelAttribute("orderItems")
which is an ArrayList
of OrderItemBean
s
Controller Code:
@RequestMapping("/order/{orderId}/save")
public String saveOrder(Map<String, Object> map, @ModelAttribute("orderItems") ArrayList<OrderItemBean> orderItems) throws Exception
{
...
}
Java Bean Code: (getters and setters implied)
public class OrderItemBean
{
String orderItemId;
String itemName;
}
I'm not sure where I'm going wrong as I am still learning about Spring.