title: POST an array of custom objects to a Struts 2 action
body: <p>How do I POST an array of custom objects to a Struts 2 action in Java?</p>
  
  <p>For example if I have the following Java object:</p>
  
  <pre><code>public class Person {
  
      private String name;
      private String lastName;
  
      public String getName() {
          return name;
      }
      public void setName(String name) {
          this.name = name;
      }
      public String getLastName() {
          return lastName;
      }
      public void setLastName(String lastName) {
          this.lastName = lastName;
      }   
  }
  </code></pre>
  
  <p>And the following Action:</p>
  
  <pre><code>public class SavePersons extends ActionSupport {
  
      private List&lt;Person&gt; persons;
  
      @Override
      public String execute() throws Exception {
              // Do something
          return SUCCESS;
      }
  
      public void setPersons(List&lt;Person&gt; persons) {
          this.persons = persons;
      }
  
  }
  </code></pre>
  
  <p>I'd like to do something like this in an HTML form:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  &lt;form method="POST" action="http://postHere"&gt;
      &lt;input type="text" name="persons[0].name" value="Name1"/&gt;
      &lt;input type="text" name="persons[0].lastName" value="LastName1"/&gt;
      &lt;input type="text" name="persons[1].name" value="Name2"/&gt;
      &lt;input type="text" name="persons[1].lastName" value="LastName2"/&gt;
      &lt;input type="submit" /&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Any tips?</p>