title: Post json to struts 2 action
body: <p>I need to post a simple json object to a Struts 2 action, could you tell me what I miss with this:</p>
  <p>the Java object to save:</p>
  <pre><code>@Id
  @GeneratedValue(strategy = IDENTITY)
  @Column(name = &quot;id&quot;, unique = true, nullable = false)
  private Integer id;
  @Column(name = &quot;code&quot;)
  private String code;
  @Column(name = &quot;libelle_fr&quot;)
  private String libelleFr;
  @Column(name = &quot;libelle_nl&quot;)
  private String libelleNl;
  </code></pre>
  <p>I use alpine.js but it's a detail, the script called to send the request is this one:</p>
  <pre><code>&lt;script&gt;
      function postForm() {
          return {
              indicateurDictionnaireForm: {
                  libelleFr: '',
                  libelleNl: '',
                  code: ''
              },
              message: '',
  
              submitData() {
                  this.message = ''
  
                  fetch('&lt;%= request.getContextPath() %&gt;/mesures.ce.save.action', {
                      method: 'POST',
                      headers: { 'Content-Type': 'application/json' },
                      dataType:&quot;json&quot;,
                      body: JSON.stringify(this.indicateurDictionnaireForm)
                  })
                      .then(() =&gt; {
                          this.message = 'Form sucessfully submitted!'
                      })
                      .catch(() =&gt; {
                          this.message = 'Ooops! Something went wrong!'
                      })
              }
          }
      }
  &lt;/script&gt;
  </code></pre>
  <p>the json sent to the action is:</p>
  <pre><code>{
  &quot;libelleFr&quot;:&quot;fr&quot;,
  &quot;libelleNl&quot;:&quot;nl&quot;,
  &quot;code&quot;:&quot;sample&quot;
  }
  </code></pre>
  <p>from my action file there is my method called from the front:</p>
  <pre><code>private IndicateurDictionnaire indicateurDictionnaireForm;
  
  // Action to save an indicateurDictionnaireto database
  @Action(value = &quot;mesures.indicateurs.ce.save&quot;, results = {
              @Result(name = &quot;success&quot;, type = &quot;json&quot;, params = {&quot;root&quot;, &quot;indicateurDictionnaireForm&quot;}),
              @Result(name = &quot;input&quot;, type = &quot;tiles&quot;, params = {&quot;root&quot;, &quot;indicateurDictionnaireForm&quot;}, location = &quot;viewMesureCoutUnitaire&quot;)})
      public String save(IndicateurDictionnaire indicateurDictionnaire, String libelleFr, String libelleNl, String code) {
          dictionnaireIndicateurBo.saveIndicateurDictionnaire(indicateurDictionnaire);
          return SUCCESS;
      }
  </code></pre>
  <p>According the struts2 json pluggin, the json should be mapped to my object if it's properly formatted but the fields are empty if I look in debug.</p>
  <p>Do you know how I can proceed to at least see the json request in my action method?</p>