title: POST array to Spring's controller via AJAX
body: <p>I am trying to send object's array to Spring controller via jQuery AJAX.
  Here is the javascript code:</p>
  
  <pre><code>var data = new Array();
              $.each(products, function (i) {
                  var temp = {};
                  temp.orpid = products[i].orpid;
                  temp.orpah = $('#orpah' + products[i].orpid).is(':checked');
                  temp.orpad = $('#orpad' + products[i].orpid).val();
                  data.push(temp);
              });
              $.postJSON(url + 'save',
                      data,
                      function(response) {
                          if (response.isAuthenticated &amp;&amp; response.isAuthorized) {
                              if (response.hasErrors) {
                                  $('#routeForm').setErrors(response.errors);
                                  hideWait();
                              }
                          }
                          else
                              redirectToLogin();
                      });
  </code></pre>
  
  <p>Here are the params that are sent to the server: </p>
  
  <pre><code>[{"orpid":10,"orpah":false,"orpad":""},{"orpid":11,"orpah":false,"orpad":""}]
  </code></pre>
  
  <p>The controller's method has following definition:</p>
  
  <pre><code>@RequestMapping(value = "/save", method = RequestMethod.POST, headers = BaseController.AJAX_HEADER)
  public ModelAndView save(@RequestBody HandlingOrderProductActionForm form, HttpServletResponse response) {...}
  </code></pre>
  
  <p>where HandlingOrderProductActionForm is:</p>
  
  <pre><code>public class HandlingOrderProductActionForm extends BaseForm {  
  public class ActionForm {
      private Boolean orpah;
      private String orpad;
      private Long orpid;
  
      public ActionForm() { }
  
      public void setOrpah(Boolean orpah) {
          this.orpah = orpah;
      }
  
      public Boolean getOrpah() {
          return orpah;
      }
  
      public void setOrpad(String orpad) {
          this.orpad = orpad;
      }
  
      public String getOrpad() {
          return orpad;
      }
  
      public void setOrpid(Long orpid) {
          this.orpid = orpid;
      }
  
      public Long getOrpid() {
          return orpid;
      }
  }
  
  private List&lt;ActionForm&gt; actions;
  
  /**
   * 
   */
  public HandlingOrderProductActionForm() {
      super();
  }
  
  public void setActions(List&lt;ActionForm&gt; actions) {
      this.actions = actions;
  }
  
  public List&lt;ActionForm&gt; getActions() {
      return actions;
  } }
  </code></pre>
  
  <p>The problem is, that the server returns an 415 error: </p>
  
  <pre><code>The server refused this request because the request entity is in a format not supported by the requested resource for the requested method ().
  </code></pre>
  
  <p>Any ideas?
  Thank you</p>