Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Spring can <a href="http://static.springsource.org/spring/docs/3.0.x/reference/validation.html#beans-beans-conventions" rel="nofollow">bind indexed properties</a>, so you need to create a list of game info objects on your command, like:</p> <pre><code>public class Command { private List&lt;Game&gt; games = new ArrayList&lt;Game&gt;(); // setter, getter } public class Game { private int id; private int awayGoals; private int homeGoals; // setters, getters } </code></pre> <p>In your controller:</p> <pre><code>@RequestMapping(value = "/test", method = RequestMethod.POST) public String test(@ModelAttribute Command cmd) { // cmd.getGames() .... return "..."; } </code></pre> <p>In your JSP you will have to set the paths for the inputs like:</p> <pre><code>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 .... </code></pre> <p>If I'm not mistaken, in Spring 3 the <a href="http://static.springsource.org/spring/docs/3.0.x/api/org/springframework/validation/DataBinder.html#setAutoGrowNestedPaths%28boolean%29" rel="nofollow">auto-growing collections</a> is now the default behavior for binding lists, but for lower versions you had to use an <a href="http://static.springsource.org/spring/docs/2.0.x/api/org/springframework/util/AutoPopulatingList.html" rel="nofollow">AutoPopulatingList</a> instead of just an ArrayList (just as a reference: <a href="http://blog.richardadamdean.com/?p=12" rel="nofollow">Spring MVC and handling dynamic form data: The AutoPopulatingList</a>).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload