title: Populate List<String> in struts2 from form data
body: <p>I feel this should be exceedingly obvious, but so far I've failed to find an answer.</p>
  
  <p>I want to have a list of strings (or an array of strings, I really don't care) get populated by form data in Struts2.</p>
  
  <p>I've seen several examples of how to do <a href="https://stackoverflow.com/questions/975883/populate-collection-from-struts2-form-submission">indexed properties with beans</a>, but wrapping a single string inside an object seems fairly silly.</p>
  
  <p>So I have something like</p>
  
  <pre><code>    public class Controller extends ActionSupport {
  
          private List&lt;String&gt; strings = new ArrayList&lt;String&gt;();
          public Controller() {
              strings.add("1");
              strings.add("2");
              strings.add("3");
              strings.add("4");
              strings.add("5");
          }
          public String execute() throws Exception {
              return ActionSupport.SUCCESS;
          }
          public List&lt;String&gt; getStrings() {
              return strings;
          }
  
          public void setStrings(List&lt;String&gt; s) {
              strings = s;
          }
      }    
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;s:iterator value="strings" status="stringStatus"&gt;
     &lt;s:textfield name="strings[%{#stringStatus.index}]" style="width: 5em" /&gt;
  &lt;/s:iterator&gt;
  </code></pre>
  
  <p>The form fields get populated with their initial values (e.g. 1, 2, etc), but the results are not properly posted back. <code>setStrings</code> is never called, but the values get set to empty strings.</p>
  
  <p>Anybody have any idea what's going on? Thanks in advance!</p>