Bird
0
0

Given this controller method:

medium📝 component behavior Q4 of 15
Spring Boot - Request and Response Handling
Given this controller method:
@RequestMapping(path = "/info", method = RequestMethod.GET)
public String getInfo() {
    return "Info Page";
}

What will be the response when a GET request is sent to "/info"?
A404 Not Found error
BInfo Page
CMethod Not Allowed error
DEmpty response
Step-by-Step Solution
Solution:
  1. Step 1: Identify the mapping and method

    The method handles GET requests to path "/info" and returns the string "Info Page".
  2. Step 2: Understand the response behavior

    When a GET request is made to "/info", the method returns "Info Page" as the response body.
  3. Final Answer:

    Info Page -> Option B
  4. Quick Check:

    GET /info returns method's string output [OK]
Quick Trick: GET request returns method's return string [OK]
Common Mistakes:
  • Expecting 404 if path matches
  • Confusing method not allowed with wrong HTTP verb
  • Assuming empty response without return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes