title: Why does Spring MVC prefer to serve application/json types over anything else?
body: <p>Given the following Spring code:</p>
  
  <pre><code>@Controller
  @RequestMapping("/somepath")
  public class SomeService {
      @RequestMapping(headers = "Accept=application/json")
      public ReturnType methodOne() {
          // stuff
      }
  
      @RequestMapping(headers = "Accept=text/html")
      public ReturnType methodTwo() {
          // stuff
      }
  }
  </code></pre>
  
  <p>I've noticed that, when a client doesn't include an "Accept" header at all, the "application/json" method is always called in preference over the text/html method. My question is - why? There's nothing to choose between them, so why prefer one over the other? I would have expected an error message instead...</p>
  
  <p>A concrete example:</p>
  
  <pre><code>@RequestMapping("/somepath")
  @Controller
  public class SomeService {
  
      @ResponseBody
      @RequestMapping(headers = "Accept=application/json")
      public ResponseEntity&lt;String&gt; methodOne() {
          return new ResponseEntity&lt;String&gt;("Method One", HttpStatus.OK);
      }
  
      @ResponseBody
      @RequestMapping(headers = "Accept=text/html")
      public ResponseEntity&lt;String&gt; methodTwo() {
          return new ResponseEntity&lt;String&gt;("Method Two", HttpStatus.OK);
      }
  
      @ResponseBody
      @RequestMapping(headers = "Accept=application/xml")
      public ResponseEntity&lt;String&gt; methodThree() {
          return new ResponseEntity&lt;String&gt;("Method Three", HttpStatus.OK);
      }
  }
  </code></pre>
  
  <p>"Method One" is always output if there are no accept headers.</p>