Created
April 3, 2021 00:58
-
-
Save kevinhooke/61eeb5ed3162fa77c7286682d1bb0170 to your computer and use it in GitHub Desktop.
JAX-RS Jersey vs Spring RestController annotations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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