title: Spring mvc @RequestBody String format
body: <p>I have one Controller : personController.java</p>
  
  <pre><code>@Controller 
  public class personController {     
  
      private static final Logger LOG = LoggerFactory.getLogger(OcaController.class);  
  
      @RequestMapping(value = "/person", method = {RequestMethod.POST, RequestMethod.GET})        
      public String ocaContract(@RequestBody String requestPerson) {
          return requestPerson;
      }    
  </code></pre>
  
  <p>1 JSP : person.jsp</p>
  
  <pre><code>&lt;html&gt;
      &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;form class="form-horizontal" METHOD="POST" ACTION="webmvc/person" ENCTYPE="x-www-form-urlencoded"&gt;
              &lt;div class="controls"&gt;
                  &lt;input type="text" name="name" id="name" value="" placeholder=""&gt;
              &lt;/div&gt;
              &lt;div class="controls"&gt;
                  &lt;input type="text" name="surname" id="surname" value="" placeholder=""&gt;
              &lt;/div&gt;
              &lt;input type="submit" value="ok"/&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and one Object Class : Person.java</p>
  
  <pre><code>@XmlRootElement(name="Person")
  public class Person {
  
  @XmlElement(required = true)
  protected String name;
  @XmlElement(required = true, nillable = true)
  protected String surname;
  
   public String getName() {
      return name;
  }
  
  public void setName(String value) {
      this.name = value;
  } ...
  </code></pre>
  
  <p>When I populate the JSP and click on the input button, my controller return this "requestPerson" string :</p>
  
  <pre><code>name=&amp;surname=
  </code></pre>
  
  <p>Is it a way to have this string as a POJO ? My final result must be at the XML format :</p>
  
  <pre><code>&lt;person&gt;
  &lt;name&gt;Lisala&lt;/name&gt;
  &lt;surname&gt;Lili&lt;/surname&gt;&lt;/person&gt;
  </code></pre>
  
  <p>I hope you ll can help me because i'm on it since 1 day now and i didn't find an easy way to accomplish this.</p>