title: Struts 2 Form Bind Parameters To Collection Without Using Index
body: <p>Struts Version: 2.3.16.3</p>
  
  <p>Is there a way to populate a list of objects without having to specify the index?  Currently I have to reference the collection like so:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;input name="myCollection[0].myProperty" value="some value" /&gt;
  </code></pre>
  
  <p>I really want to be able to do something like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;input name="myCollection[].myProperty" value="some value" /&gt;
  </code></pre>
  
  <p>I am dynamically adding and removing elements on the page with JavaScript and it has been a pain to get the indexing right with the JavaScript.  Rather just have the backend add to the end of the collection in the order the elements come across from the form.  Similar to how PHP processes it.</p>
  
  <p>The docs for the <a href="https://struts.apache.org/docs/parameters-interceptor.html" rel="nofollow">parameters interceptor</a> say that it is really just a ognl expression that the input name is binding to.  I went to the <a href="https://commons.apache.org/proper/commons-ognl/language-guide.html" rel="nofollow">ognl docs</a> and it says you can reference array's like this:</p>
  
  <pre class="lang-xml prettyprint-override"><code>array["length"]
  </code></pre>
  
  <p>which would be the next element in the array.  The parameter interceptor is spitting out a message that it is rejecting this parameter name.  I would really like to find a way to make this happen, even if it means extending the parameters interceptor.</p>