Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kevinhooke/61eeb5ed3162fa77c7286682d1bb0170 to your computer and use it in GitHub Desktop.
Save kevinhooke/61eeb5ed3162fa77c7286682d1bb0170 to your computer and use it in GitHub Desktop.
JAX-RS Jersey vs Spring RestController annotations
JAX-RS Jersey Spring RestController
------------- ---------------------
@Path("/examplepath") @RestController
@RequestMapping("/examplepath")
@GET("/item") @GetMapping("/item")
@Produces(MediaType.APPLICATION_JSON)
@QueryParam("id") @RequestParam("id") // e.g. /example?id=123
@PathParam("id") @PathVariable("id") //e.g. /example/{id}/detail
@POST("item") @PostMapping("/item")
@RequestBody YourPojo body
Notes:
Spring MVC @Controller uses same @GetMapping, @PostMapping, but requires additional @ResponseBody on the method return
to indicate pojo for the reponse
Spring @RestController use same mappings, but @ResponseBody is implied
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment