Week 7 Spring Web Annotations Flashcards

1
Q

What is the @Controller Annotation?

A

@Controller: specifies a class as a controller, which is a special bean used to handle web application requests

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the @ResponseBody annotation?

A

@ResponseBody: converts a Java object that we are returning from a controller method into JSON

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the @PathVariable annotation?

A

@PathVariable: Used to bind “path parameters” ex: /users/{id} where id is the path parameter, to a variable in the method parameters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the @RequestParam annotation?

A

@RequestParam: used to bind “query parameters” ex: ?amountLessThan=2000 to a variable in the method parameters (or form-data)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the @RequestBody annotation?

A

@RequestBody: allows Spring to map JSON from the body of a request into a Java Object

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the @RestController annotation?

A

@RestController: the same as @Controller, but automatically adds @ResponseBody to each return type in the controller methods

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the Request Mappings?

A

@RequestMapping
@GetMapping
@PostMapping
@PutMapping
@DeleteMapping
@PatchMapping

How well did you know this?
1
Not at all
2
3
4
5
Perfectly