title: Create List<Class> from Ajax JSON javascript to Spring Controller
body: <p>Hi I am trying to call method using <code>Ajax</code> to <code>Spring Controller</code>. The problem is that the object I have created in javascript variable is ok but controller can't bind the attribute in class that is List object. How To correctly binding the array of object in javascript to List Class in Java? I have also already tried to use <code>JSON.stringify()</code> and <code>JSON.parse()</code> but it doesn't work and I get errors.</p>
  
  <p>Js Code:</p>
  
  <pre><code> $('#btnApprove').click(function(e){
              //TODO Function for approval
              var checkedProductList = [];
              $('input[type=checkbox]').each(function (index) {
                  var isChecked = (this.checked ? $(this).val() : "");
                  if(isChecked === "1") {
                      checkedProductList.push(productListAll[index]);
                  }
              });
              console.log(checkedProductList);
              var parameters = {};
              parameters["totalNumber"] = totalNumber;
              parameters["listProductNumber"] = productNumber;
              parameters["list"] = checkedProductList;
  
              console.log(parameters);
  
              sendJSONRequest("POST", 
                  CONSTANTS.baseUrl + "product/approval/approve.do", JSON.stringify(parameters), 
                      function(res) {
                          if(res.succeeded) {
                              console.log("success");
                          }
                          console.log("failed");
              });
  
          });
  </code></pre>
  
  <p>Java Code:</p>
  
  <pre><code> @RequestMapping(value = "/approve.do" , method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
      @ResponseBody
      public ResponseEntity&lt;String&gt; approve(ProductApproval productApproval) {
          List&lt;ProductApprovalItem &gt; list =  productApproval.getList();
          LOG.info("Result: " + list);
          if(list==null || list.isEmpty()) {
              //do something...
          }
          //do something...
      }
  
  public class ProductApprovalItem{
  
      private String productName;
  
      private Long sellingPrice;
  
      private String brandName;
  
      private String category;
  
      private String imageUrl;
  
      /**
       * @return the productName
       */
      public String getProductName() {
          return productName;
      }
  
      /**
       * @return the sellingPrice
       */
      public Long getSellingPrice() {
          return sellingPrice;
      }
  
      /**
       * @return the brandName
       */
      public String getBrandName() {
          return brandName;
      }
  
      /**
       * @return the mainCategory
       */
      public String getCategory() {
          return category;
      }
  
      /**
       * @return the imageUrl
       */
      public String getImageUrl() {
          return imageUrl;
      }
  
      /**
       * @param productNumber the productNumber to set
       */
      public void setProductNumber(String productNumber) {
          this.productNumber = productNumber;
      }
  
      /**
       * @param productName the productName to set
       */
      public void setProductName(String productName) {
          this.productName = productName;
      }
  
      /**
       * @param sellingPrice the sellingPrice to set
       */
      public void setSellingPrice(Long sellingPrice) {
          this.sellingPrice = sellingPrice;
      }
  
      /**
       * @param brandName the brandName to set
       */
      public void setBrandName(String brandName) {
          this.brandName = brandName;
      }
  
      /**
       * @param mainCategory the mainCategory to set
       */
      public void setCategory(String category) {
          this.category= category;
      }
  
      /**
       * @param imageUrl the imageUrl to set
       */
      public void setImageUrl(String imageUrl) {
          this.imageUrl = imageUrl;
      }
  
  }
  </code></pre>
  
  <p>Error message: "Property referenced in indexed property path is neither an array nor a List nor a Map"</p>