title: Spring RequestMapping for controllers that produce and consume JSON
body: <p>With multiple Spring controllers that consume and produce <code>application/json</code>, my code is littered with long annotations like:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @RequestMapping(value = "/foo", method = RequestMethod.POST,
              consumes = MediaType.APPLICATION_JSON_VALUE,
              produces = MediaType.APPLICATION_JSON_VALUE)
  </code></pre>
  
  <p>Is there a way to produce a "composite/inherited/aggregated" annotation with <strong>default</strong> values for <code>consumes</code> and <code>produces</code>, such that I could instead write something like:</p>
  
  <pre class="lang-java prettyprint-override"><code>    @JSONRequestMapping(value = "/foo", method = RequestMethod.POST)
  </code></pre>
  
  <p>How do we define something like <code>@JSONRequestMapping</code> above?  Notice the <code>value</code> and <code>method</code> passed in just like in <code>@RequestMapping</code>, also good to be able to pass in <code>consumes</code> or <code>produces</code> if the default isn't suitable.</p>
  
  <p>I need to control what I'm returning.  I want the <code>produces</code>/<code>consumes</code> annotation-methods so that I get the appropriate <code>Content-Type</code> headers.</p>