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