title: spring rest client, how to serialize object in client request
body: <p>On client I have</p>
  
  <pre><code>RestTemplate restTemplate = new RestTemplate();
  Result r = restTemplate.getForObject("http://localhost:8080/test?key1=value1",Result.class);
  </code></pre>
  
  <p>I don't want to manually append "key1=value1" to the url, is it possible to have a class like</p>
  
  <pre><code>class Dto {
    private String key1;
    public void setKey1(String key1) {this.key1=key1}
  </code></pre>
  
  <p>and have spring to automatically serialize the dto object, so the call would be like</p>
  
  <pre><code>Result r = restTemplate.getForObject("http://localhost:8080/test", Result.class, dto);
  </code></pre>
  
  <p>There is such method in restTemplate, but I can't get it to work, on server side I receive empty object.
  I guess I am missing some annotations on the DTO. 
  On server I have</p>
  
  <pre><code>@RequestMapping(value = "/test")
  @ResponseBody
  public DTO test(DTO p) {
      p.setName("received");
      return p;
  }
  </code></pre>
  
  <p>Please advice. </p>