title: How to access a modelAttribute with variable name from jQuery
body: <p>I'm using Spring MVC and jQuery for processing in the JSP the objects sent by the controller.</p>
  
  <p>My controller is sending to the JSP multiple objects using:</p>
  
  <pre><code>modelAndView.addObject("roleForm" + rol.getRolecode(), form);
  </code></pre>
  
  <p>Where form is an object of the following class:</p>
  
  <pre><code>public class RoleForm
  {
      private String roleCode;
      private LinkedHashSet&lt;String&gt; listEnabled;
  ... getters and setters ...
  }
  </code></pre>
  
  <p>So, I'm sending objects with the key roleFormADMIN, roleFormUSER, etc. The quantity and names of these objects are not known, as they are retrieved from database.</p>
  
  <p>In my JSP I'm accessing, for each rol, its correspondent RoleForm:</p>
  
  <pre><code>&lt;c:forEach items="${rolesList}" var="role"&gt;
      &lt;div class="role" id="${role}"&gt;
          &lt;label class="adminSectionTitle"&gt;
              ${role}
          &lt;/label&gt;
  
          &lt;form:form method="post" id="roleForm${role}" modelAttribute="roleForm${role}" action="roles.html"&gt;
              &lt;fieldset&gt;
                  &lt;form:hidden path="roleCode"/&gt;
  
                  &lt;div class="pickList"&gt;
                      &lt;fieldset class="pickItems"&gt;
                          &lt;legend &gt;Enabled&lt;/legend&gt;
  
                          &lt;form:select  path="listFunctEnabled" id="combo1" size="5" multiple="true"&gt;     
                              &lt;form:options items="${listFunctEnabled}" /&gt;
                          &lt;/form:select&gt;
                      &lt;/fieldset&gt;
  
                  &lt;/div&gt;
              &lt;/fieldset&gt;
              &lt;div class="formButtons"&gt;                       
                  &lt;input type="submit" value="&lt;fmt:message key="button.save"/&gt;" /&gt;
                  &lt;input type="button" name="reset" onclick="location.href='&lt;c:url value="roles.html"/&gt;'" value="&lt;fmt:message key="button.clear"/&gt;" /&gt;                                                
              &lt;/div&gt;
          &lt;/form:form&gt;        
      &lt;/div&gt;
  &lt;/c:forEach&gt;            
  </code></pre>
  
  <p>The property roleCode of each RoleForm is correctly retrieved, but it can't access the property listFunctEnabled of the form (it's empty). </p>
  
  <p>If I directly write the name of the form (for instance, roleFormADMIN.listFunctEnabled), then it writes every item of the list in the form:option.</p>
  
  <p>If I use roleForm${role}.listFunctEnabled, then it considers this as an String and says that String has not any property called listFunctEnabled.</p>
  
  <p>I need one form for each role as I need one button for each role in order to update its list of functenabled.</p>
  
  <p>How could I achieve this?</p>