title: How to set the default content type in Spring MVC in no Accept header is provided?
body: <p>If a request is sent to my API without an Accept header, I want to make JSON the default format. I have two methods in my controller, one for XML and one for JSON:</p>
  
  <pre><code>@RequestMapping(method = RequestMethod.GET,produces=MediaType.APPLICATION_ATOM_XML_VALUE)
  @ResponseBody
  public ResponseEntity&lt;SearchResultResource&gt; getXmlData(final HttpServletRequest request) {
       //get data, set XML content type in header.
   }
  
   @RequestMapping(method = RequestMethod.GET, produces=MediaType.APPLICATION_JSON_VALUE)
   @ResponseBody
   public ResponseEntity&lt;Feed&gt; getJsonData(final HttpServletRequest request){
        //get data, set JSON content type in header.  
   }
  </code></pre>
  
  <p>When I send a request without an Accept header the <code>getXmlData</code> method is called, which is not what I want. Is there a way to tell Spring MVC to call the <code>getJsonData</code> method if no Accept header has been provided? </p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>There is a <code>defaultContentType</code> field in the <code>ContentNegotiationManagerFactoryBean</code> that does the trick.</p>