java - Automatically add "headers" and "produces" attributes to my @RequestMapping -


I have applied a REST API through Spring MVC. Here is an example of mapping:

  @ requestmapping (value = "/ video", method = RequestMethod.GET, header = "accept = application / JSON ", produces =" app / JS ")   

Many of them are there, so I wonder what factorize headers < / Code> and output attributes, so I do not have to specify them in each mapping, so that my code is lightweight Possible?

Best custom annotation will automatically set two attributes, for example:

  @JsonRequestMapping ( Value = "/ video", method = RequestMethod.GET)   

but I am not able to implement any such ...

You can also insert (see) a code next to a method next to @RequestMapping . If you want globally available features, then a @RequestMapping is inserted on one class, then this method will be merged with one.

  @Controller @RequestMapping (header = "Your Controller {...}   

Your method only includes the method and URL.

  @RequestMapping (value = "/ video", method = RequestMethod.GET) Public Objects Some Methods (...) {...}   

You can also take Take a look at this may want to go because it also configures some defaults for your controller. @ResponseBody should no longer be used on your own methods. @RestController Public Class YourController {...}

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -