Bird
0
0

Identify the error in this mapping:

medium📝 Debug Q6 of 15
Spring Boot - Request and Response Handling
Identify the error in this mapping:
@RequestMapping(path = "/delete", method = "DELETE")
public String deleteItem() {
    return "Deleted";
}
Apath attribute cannot be used with method
Bmethod attribute should be RequestMethod.DELETE, not a string
CMethod name must be delete, not deleteItem
DReturn type must be void for DELETE
Step-by-Step Solution
Solution:
  1. Step 1: Check method attribute type

    The method attribute expects an enum value like RequestMethod.DELETE, not a string "DELETE".
  2. Step 2: Confirm correct usage

    Using a string causes a syntax error; correct usage is method = RequestMethod.DELETE.
  3. Final Answer:

    method attribute should be RequestMethod.DELETE, not a string -> Option B
  4. Quick Check:

    method attribute requires enum, not string [OK]
Quick Trick: Use RequestMethod.DELETE enum, not string "DELETE" [OK]
Common Mistakes:
  • Passing HTTP method as string instead of enum
  • Thinking path and method cannot be combined
  • Assuming method name or return type matters here

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes