title: ModelAttribute not working with lists in spring
body: <p>I want to bind a List using ModelAttribute. The list contains objects of type Transaction each of which contains transactionid (type int). This is my controller code:</p>
  
  <pre><code>@RequestMapping(value = "/approvecreditdebit.do", method = RequestMethod.POST)
      public ModelAndView doActions(HttpServletRequest request,
              @ModelAttribute("clc") Clc transactionList, BindingResult result,
              ModelMap model) {
          /*
           * switch (action) { case "approve":
           */
  
          System.out.println("Obj = " + transactionList.getClass());
          System.out.println("Val = " + transactionList.getTransactionList());
          Users users = new Users();
          return new ModelAndView("internal","internal",users);
      }
  </code></pre>
  
  <p>This is my jsp code:</p>
  
  <pre><code>&lt;form:form action="approvecreditdebit.do" method="POST"
      modelAttribute="clc"&gt;
  
      &lt;table border="1"&gt;
          &lt;tr&gt;
              &lt;th&gt;no&lt;/th&gt;
              &lt;th&gt;ID&lt;/th&gt;
          &lt;/tr&gt;
  
          &lt;c:forEach items="${clc.transactionList}"
              var="transaction" varStatus="status"&gt;
              &lt;tr&gt;
                  &lt;td&gt;${status.index}&lt;/td&gt;
                  &lt;td&gt;&lt;input name = "transaction[${status.index}].transactionId"
                          value="${transaction.transactionId}" /&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/c:forEach&gt;
      &lt;/table&gt;
  
      &lt;br&gt;
      &lt;br&gt;
  
      &lt;center&gt;
          &lt;input type="submit" value="approve" /&gt;
      &lt;/center&gt;
  
  
  &lt;/form:form&gt;
  </code></pre>
  
  <p>This is the Clc class:</p>
  
  <pre><code>public class Clc{
  
      private List&lt;Transaction&gt; transactionList;
  
      public List&lt;Transaction&gt; getTransactionList() {
          return transactionList;
      }
  
      public void setTransactionList(List&lt;Transaction&gt; transactionList) {
          this.transactionList = transactionList;
      }    
  }
  </code></pre>
  
  <p>The value of transactionList is not being set to the values received from the form. I receive the following error:</p>
  
  <pre><code>Request processing failed; nested exception is java.lang.NullPointerException
  </code></pre>
  
  <p>I tried searching for the solution on google and got a lot of solutions from stackoverflow but none of them seem to work.</p>