由于多个Spring控制器消耗并产生application/json
个,我的代码中充满了长注释,比如:
@RequestMapping(value = "/foo", method = RequestMethod.POST,
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE)
有没有办法生成一个"复合/继承/聚合"注释,其中consumes
和produces
的值为default,这样我就可以编写如下内容:
@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.