0
0
Spring Bootframework~10 mins

@PutMapping and @DeleteMapping in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a method that handles HTTP PUT requests.

Spring Boot
@[1]("/update")
public ResponseEntity<String> updateItem() {
    return ResponseEntity.ok("Item updated");
}
Drag options to blanks, or click blank then click option'
APutMapping
BGetMapping
CPostMapping
DDeleteMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @GetMapping instead of @PutMapping
Using @PostMapping for updates
Confusing @DeleteMapping with @PutMapping
2fill in blank
medium

Complete the code to create a method that handles HTTP DELETE requests.

Spring Boot
@[1]("/delete/{id}")
public ResponseEntity<String> deleteItem(@PathVariable Long id) {
    return ResponseEntity.ok("Item deleted");
}
Drag options to blanks, or click blank then click option'
APutMapping
BGetMapping
CDeleteMapping
DPostMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @PutMapping instead of @DeleteMapping
Using @GetMapping for deletions
Missing @PathVariable annotation
3fill in blank
hard

Fix the error in the method annotation to correctly handle HTTP PUT requests.

Spring Boot
@[1]("/modify")
public ResponseEntity<String> modifyItem() {
    return ResponseEntity.ok("Item modified");
}
Drag options to blanks, or click blank then click option'
ADeleteMapping
BRequestMapping(method = RequestMethod.PUT)
CPutMapping
DPostMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @DeleteMapping for PUT requests
Using @PostMapping instead of PUT
Missing method attribute in @RequestMapping
4fill in blank
hard

Fill both blanks to create a method that handles HTTP DELETE requests and extracts the path variable.

Spring Boot
@[1]("/remove/{id}")
public ResponseEntity<String> removeItem(@[2] Long id) {
    return ResponseEntity.ok("Removed item " + id);
}
Drag options to blanks, or click blank then click option'
ADeleteMapping
BPutMapping
CPathVariable
DRequestParam
Attempts:
3 left
💡 Hint
Common Mistakes
Using @RequestParam instead of @PathVariable
Using @PutMapping instead of @DeleteMapping
Forgetting to annotate the method parameter
5fill in blank
hard

Fill all three blanks to create a method that handles HTTP PUT requests, extracts a path variable, and consumes JSON data.

Spring Boot
@[1](value = "/edit/{id}", consumes = "application/json")
public ResponseEntity<String> editItem(@[2] Long id, @[3] Item item) {
    return ResponseEntity.ok("Edited item " + id);
}
Drag options to blanks, or click blank then click option'
APutMapping
BPathVariable
CRequestBody
DDeleteMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @DeleteMapping instead of @PutMapping
Using @RequestParam instead of @PathVariable
Forgetting @RequestBody for JSON input