@PutMapping("/items/{id}")
public void updateItem(@PathVariable String id, @RequestBody Item item) {
// update logic
}When a @PutMapping method returns void, Spring Boot by default sends HTTP 200 OK with an empty body, indicating the request was successful but no content is returned.
@DeleteMapping("/users/{id}") public ResponseEntity deleteUser(@PathVariable Long id) { userService.delete(id); return ResponseEntity.ok().build(); }
The method call userService.delete(id) is missing a semicolon at the end, causing a syntax error.
@PutMapping("/products/{id}") public ResponseEntity<Product> updateProduct(@PathVariable Long id, @RequestBody Product product) { Product updated = productService.update(id, product); return ResponseEntity.ok(updated); }
The method returns ResponseEntity.ok(updated), so the updated Product object is serialized to JSON and sent in the response body with HTTP 200 status.
@GetMapping("/orders/{id}") public Order getOrder(@PathVariable Long id) { return orderService.findById(id); }
The controller only has a @GetMapping for /orders/{id}, so DELETE requests to that URL are not handled, causing 405 error.
@PutMapping corresponds to HTTP PUT which is idempotent and used for updating resources. @DeleteMapping corresponds to HTTP DELETE which is also idempotent and used to delete resources.
