samedi 4 avril 2015

How to setup default success status codes for mapped HttpMethods Spring MVC @RestControllers?

Hi there Spring Gurus,


Currently we are annotating every mapped @RestController method with it's own success @ResponseStatus. I wonder, if there is a possibility for a global setup, based on the mapped @RequestMapping method. On Success we'd like to have:



  • GET -> HttpStatus.OK

  • POST -> HttpStatus.CREATED

  • PUT -> HttpStatus.OK

  • PATCH -> HttpStatus.OK

  • DELETE -> HttpStatus.NO_CONTENT


If possible at all, what do we have to do?


Best regards, Marius


Aucun commentaire:

Enregistrer un commentaire