title: HTTP Array Parameters with Struts 2 via an Ajax Call
body: <p>I'm having an issue sending array parameters to a Struts 2 action class.  I am using struts 2.1.8.1.</p>
  
  <p>Here is some example code:</p>
  
  <pre><code>public class MyAction extends ActionSupport {
  
      private String[] types;
  
      public String execute() {
          return SUCCESS;
      }
  
      public String[] getTypes() {
          return types;
      }
  
      public void setTypes(String[] types) {
          this.types = types;
      }
  }
  </code></pre>
  
  <p>The problem is when sending an array via the jquery ajax method:</p>
  
  <pre><code>$.ajax({
      type: 'POST',
      url: 'Myaction.action',
      data: {
          types: ["this", "is", "a", "test"]
      }
  });
  </code></pre>
  
  <p>causes an exception to occur:</p>
  
  <p><code>ognl.ParseException: Encountered " "]" "] "" at line 1, column 7.</code></p>
  
  <p>How can I use jQuery to send the array to my Struts2 action class? Is there something along the lines of an interceptor that I need to include? Or is there an option in jQuery to remove this?</p>
  
  <p>I also encountered this problem with the jQuery UI Sortable control, but I solved that using a regex to remove the "[]" characters.  I would like to avoid that, because that solution bothers me.  I suppose I could just build the string myself, instead of using the object notation, but unless you can convince me otherwise, I would like to use the object notation instead.</p>