title: Using @RequestMapping(headers = "Accept=application/json") in SpringMVC4
body: <p>I am using Spring MVC 4 and I want to know that I am using <code>@RestController</code> at class level and for one of its method I am  Using <code>@RequestMapping(headers = "Accept=application/json")</code>. Now can any one tell me why just by using <code>&lt;mvc:annotation-driven /&gt;</code> in my <code>config-servlet.xml</code> how I am getting the response in <code>JSON</code> on my browser. I mean using header attribute is only saying that this method can only respond to requests having this type of  headers. How does the MVC4 knows to respond in <code>JSON</code> on browser. Here is my code:</p>
  
  <p><strong>My config-servlet.xml</strong></p>
  
  <pre><code>&lt;beans&gt;
  &lt;context:component-scan base-package="com.songs.service.controller" /&gt;
  &lt;mvc:annotation-driven /&gt;
  &lt;/beans&gt;
  </code></pre>
  
  <p><strong>My RestController Class</strong></p>
  
  <pre><code>@RestController
  @RequestMapping("/songappWS")
  public class SongServiceWS 
  { 
  @RequestMapping(value = "/topmoviesWS", method = RequestMethod.GET, headers="Accept=application/json")
  public List&lt;?&gt; getTopMoviesWS() {
  //method logic
  return l1;
  
  }
  }
  </code></pre>