title: Different response entity body based on accept header with Spring WebMVC REST controller
body: <p>I have a controller with a method signature like this</p>
  
  <pre><code>@RequestMapping(value = "/{project:[A-Z0-9_+\\.\\(\\)=\\-]+}", method = RequestMethod.GET)
  public ResponseEntity&lt;Object&gt; lookupProject(@PathVariable String project,
          @RequestParam(value = "fields", required = false) String fields,
          @RequestParam(value = "asList", required = false, defaultValue = "false") boolean asList);
  </code></pre>
  
  <p>I am returning for JSON a <code>Collection&lt;Object&gt;</code> or <code>Map&lt;String, Object&gt;</code>. This isn't suitable for XML. I'd rather return a <code>Project</code> object.</p>
  
  <p>Is there a clean way to determine which content type will be produced? The work-around would be another method which produces XML only and returns the <code>Project</code> object. I'd rather like to avoid duplicate code.</p>
  
  <p>I am on Spring 3.1.3-RELEASE.</p>