Week 7 Spring Web Annotations Flashcards
What is the @Controller Annotation?
@Controller: specifies a class as a controller, which is a special bean used to handle web application requests
What is the @ResponseBody annotation?
@ResponseBody: converts a Java object that we are returning from a controller method into JSON
What is the @PathVariable annotation?
@PathVariable: Used to bind “path parameters” ex: /users/{id} where id is the path parameter, to a variable in the method parameters
What is the @RequestParam annotation?
@RequestParam: used to bind “query parameters” ex: ?amountLessThan=2000 to a variable in the method parameters (or form-data)
What is the @RequestBody annotation?
@RequestBody: allows Spring to map JSON from the body of a request into a Java Object
What is the @RestController annotation?
@RestController: the same as @Controller, but automatically adds @ResponseBody to each return type in the controller methods
What are the Request Mappings?
@RequestMapping
@GetMapping
@PostMapping
@PutMapping
@DeleteMapping
@PatchMapping