Spring can bind indexed properties , so you need to create a list of game information objects in your team, for example:
public class Command { private List<Game> games = new ArrayList<Game>();
In your controller:
@RequestMapping(value = "/test", method = RequestMethod.POST) public String test(@ModelAttribute Command cmd) { // cmd.getGames() .... return "..."; }
In your JSP, you will need to set the paths for the inputs, for example:
games[0].id games[0].awayGoals games[0].homeGoals games[1].id games[1].awayGoals games[1].homeGoals games[2].id games[2].awayGoals games[2].homeGoals ....
If I'm not mistaken, in Spring 3, auto-growth collections are now the default behavior for binding lists, but for lower versions you had to use an AutoPopulatingList instead of just an ArrayList (as a reference: Spring MVC and dynamic form data processing: AutoPopulationList ).
source share