title: Trying to create and save list of objects in spring mvc
body: <p>This is my model class </p>
  
  <pre><code>public class DynamicRow {       
          private String id;
          private String name;
          private String email;
  
          public DynamicRow(String id, String name, String email) {
              this.id = id;
              this.name = name;
              this.email = email;
          }
          public DynamicRow() {
              // TODO Auto-generated constructor stub
          }
          public String getId() {
              return id;
          }
          public void setId(String id) {
              this.id = id;
          }
          public String getName() {
              return name;
          }
          public void setName(String name) {
              this.name = name;
          }
          @Override
          public String toString() {
              return "DynamicRow [id=" + id + ", name=" + name + ", email=" + email
                      + "]";
          }
          public String getEmail() {
              return email;
          }
          public void setEmail(String email) {
              this.email = email;
          }
      }
  </code></pre>
  
  <p>This is the form class</p>
  
  <pre><code>public class DynamicRowForm {
  
      private List&lt;DynamicRow&gt; dynamicRow = LazyList.decorate(new ArrayList&lt;DynamicRow&gt;(), FactoryUtils.instantiateFactory(DynamicRow.class));
      public DynamicRowForm() {
  
      }
      public List&lt;DynamicRow&gt; getDynamicRow() {
          return dynamicRow;
      }
  
      public void setDynamicRow(List&lt;DynamicRow&gt; dynamicRow) {
          this.dynamicRow = dynamicRow;
      }
  }
  </code></pre>
  
  <p>Below is my controllers</p>
  
  <pre><code>@RequestMapping(value="/createDetails")
      public String list(Model model){
          DynamicRowForm dynamicRowForm = new DynamicRowForm();
          model.addAttribute("DynamicRowForm",dynamicRowForm);
  
          return "test2";
      }
  
      @RequestMapping(value="/save")
      public String showList(Model model,@ModelAttribute("DynamicRowForm") DynamicRowForm dynamicRowForm) {
          System.out.println(dynamicRowForm.getDynamicRow());
          return "success";
      }
  </code></pre>
  
  <p>And this is my jsp page named as test2</p>
  
  <pre><code>&lt;%@taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;head&gt;
  &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
  var rowCount = 1;
  function addMoreRows(form) {
  rowCount ++;
  var recRow = '&lt;p id="rowCount'+rowCount+'"&gt;&lt;tr&gt;&lt;td&gt;&lt;input name="" type="text" size="17%"  maxlength="120" /&gt;&lt;/td&gt;&lt;td&gt;&lt;input name="" type="text"  maxlength="120" style="margin: 4px 5px 0 5px;"/&gt;&lt;/td&gt;&lt;td&gt;&lt;input name="" type="text" maxlength="120" style="margin: 4px 10px 0 0px;"/&gt;&lt;/td&gt;&lt;/tr&gt; &lt;a href="javascript:void(0);" onclick="removeRow('+rowCount+');"&gt;Delete&lt;/a&gt;&lt;/p&gt;';
  $('#addedRows').append(recRow);
  }
  
  function removeRow(removeNum) {
  $('#rowCount'+removeNum).remove();
  }
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form:form action="save" method="GET" modelAttribute="DynamicRowForm"&gt;
  &lt;input type="button" onclick="addMoreRows(this.form);" value="AddRow"&gt;
  &lt;table rules="all" style="background:#fff;"&gt;
  &lt;tr&gt;
  &lt;td style="font-size:14px;" &gt;Name&lt;/td&gt;
  &lt;td style="font-size:14px;"&gt;Email&lt;/td&gt;
  &lt;td style="font-size:14px;"&gt;Mobile&lt;/td&gt;
  &lt;!-- &lt;td&gt;&lt;span style="font:normal 12px agency, arial; color:blue; text-decoration:underline; cursor:pointer;" onclick="addMoreRows(this.form);"&gt;
  Add More
  &lt;/span&gt;
  &lt;/td&gt; --&gt;
  &lt;/tr&gt;
   &amp;nbsp;
  &lt;tr id="rowId"&gt;
  
  &lt;td&gt;&lt;form:input path="${dynamicRow.id}"  type=""   size="17%"/&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input path="${dynamicRow.name}"  type="text"   /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;form:input path="${dynamicRow.email}"  type="text"   /&gt;&lt;/td&gt;
  &lt;/table&gt;
  &lt;div id="addedRows"&gt;&lt;/div&gt;
  &lt;input type="submit" value="Save"&gt;
  &lt;/form:form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p>I know these questions have been asked before, but as am very new to spring mvc and learning things so am trying to get some comfort in this technology..</p>
  
  <p>Anyway, what here I am trying to do is to save multiple row/list of object... but its not getting saved in the list... Please help me out on what is the mistake am doing, and correct me.</p>
  
  <p><strong>Edit</strong>
  And one more thing I would like to clarify, in my first controller am creating a dynamicRowForm object and adding into model so that my jsp page can access it...and in my second controller am receiving DynamicRowForm object using @ModelAttribute with same name..but here am getting different object.why?</p>