title: How to send JSON to Struts2 Action with AngularJS form?
body: <p>How to send JSON to Struts2 Action with AngularJS form?</p>
  
  <p>My code:</p>
  
  <p>My struts.xml</p>
  
  <pre><code>&lt;package name="default" extends="json-default"&gt;
  
      &lt;interceptors&gt;
          &lt;interceptor-stack name="defaultStack"&gt;
              &lt;interceptor-ref name="json"&gt;
                  &lt;param name="enableSMD"&gt;true&lt;/param&gt;
              &lt;/interceptor-ref&gt;
          &lt;/interceptor-stack&gt;
      &lt;/interceptors&gt;
  
      &lt;default-interceptor-ref name="defaultStack" /&gt;
  
      &lt;action name="angularAction" class="actions.CustomerAction" method="findCustomer" &gt;
          &lt;result type="json"&gt;
                &lt;param name="root"&gt;customer&lt;/param&gt;
                &lt;param name="excludeNullProperties"&gt;true&lt;/param&gt;
                &lt;param name="noCache"&gt;true&lt;/param&gt;
          &lt;/result&gt;
      &lt;/action&gt;
  
  &lt;/package&gt;
  </code></pre>
  
  <p>My Java Class:</p>
  
  <pre><code>public class Customer {
  
      private String id;
      private String name;
      private String email;
      private String phone;
  
      public Customer() {
  
      }
  
      public Customer(String id, String name, String email, String phone) {
  
          this.id = id;
          this.name = name;
          this.email = email;
          this.phone = phone;
  
      }
  
      //getters and setters omitted
  }
  </code></pre>
  
  <p>My Struts2 Action</p>
  
  <pre><code>public class ClienteAction extends ActionSupport {
  
      private List&lt;Customer&gt; jsonCustomer;
  
      public List&lt;Customer&gt; getJsonCustomer() {
          return jsonCustomer;
      }
  
  
      public void setJsonCustomer(List&lt;Customer&gt; jsonCustomer) {
          this.jsonCustomer = jsonCustomer;
      }
  
      public String findCustomer() {
  
          List&lt;Customer&gt; jc = getJsonCustomer();
  
          return SUCCESS;
  
      }
  
  }
  </code></pre>
  
  <p>My Angular Code:</p>
  
  <pre><code>angular.module('myApp', []);
  
  angular.module('myApp').
  controller('MyController',  function ($scope, $http) {
      $scope.getDataFromServer = function(customer) {
  
          var data1 = JSON.stringify(customer);
  
              $http({
                  url: 'angularAction?jasonCustomer=' + data1,
                  method: 'GET'
              }).then (function successCallback(response) {
                  $scope.customer = response.data;                    
  
              }, function errorCallback(response) {
                  console.log(response.data) ;
              })      
  
          };
      });
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/m4K2u.png" rel="nofollow">My Libs</a></p>
  
  <p>It doesn't work! The variable jsonCustomer in angularAction is null.</p>
  
  <p>I'm newbie with angular. I'm using this tutorial, but angular instead jquery.</p>
  
  <p><a href="http://tech.learnerandtutor.com/send-json-object-to-struts-2-action-by-jquery-ajax/" rel="nofollow">http://tech.learnerandtutor.com/send-json-object-to-struts-2-action-by-jquery-ajax/</a></p>
  
  <p>Thanks by help!</p>