title: Can we serialize and send a form with a list of objects inside the main object - Ajax, Spring MVC
body: <p>I am sorry that I cannot share my code. I will try to give an appropriate example for my situation.</p>
  
  <p>Class Person:</p>
  
  <pre><code>    public class Community {
  
         private int personCount;
         private List&lt;Person&gt; persons;
  
         //getters and setters for all
     }
  </code></pre>
  
  <p>Call Person:</p>
  
  <pre><code>   public class Person {
  
         private int name;
         private int age;
  
         //getters and setters
    }
  </code></pre>
  
  <p>Now, I want to serialize and send a form with an AJAX call from my JSP. 
  In JSP, I used </p>
  
  <pre><code>&lt;div th:each="parameter,iterStat : ${persons}" class="personsContainer"&gt;
    &lt;div th:text="'Name: ' + ${parameter.name}"&gt;&lt;/div&gt;
     ...
  </code></pre>
  
  <p>to traverse through the list.</p>
  
  <p>This is the AJAX call</p>
  
  <pre><code>   function updateCommunityPeople(initial) {
  
                  var getValuesUrl = /*[[@{/getPeoplesJson}]]*/ "";
                  var data = $(".personsContainer").parents('form:first').serialize();
  
                  data += "&amp;initial=" + initial;
                  alert("date: "+data);
  
                  $.ajax({
                      'type': "POST",
                      'url': getValuesUrl,
                      'dataType': "json",
                      'data': data,
                  })
                  .done(function (data, textStatus, jqXHR) {
                      alert("Updated successfully");
                   });
        }
  </code></pre>
  
  <p>My controller method:</p>
  
  <pre><code>     @RequestMapping(value = "/getPeoplesJson", method = RequestMethod.POST)
  public @ResponseBody String getCommunityPeopleValuesJson(HttpServletRequest request, HttpSession session,
          Locale locale, Model model, Device device, Principal principal, @Valid Community post,
          BindingResult result)
  {
      int count = post.getPersonCount();
      if (post != null &amp;&amp; post.getPersons() != null)
      {
          //calls to service and so on...
          return "true";
      }
      return false;
  }
  </code></pre>
  
  <p>Here, I am able to retrieve the person count correctly but the whole issue is with the list of Persons. It is null always...</p>