Bird
0
0

Which of the following is the correct syntax to map a GET request to the URL /welcome using @GetMapping?

easy📝 Syntax Q3 of 15
Spring Boot - REST Controllers
Which of the following is the correct syntax to map a GET request to the URL /welcome using @GetMapping?
A@GetMapping(value = \"/welcome\", method = RequestMethod.GET)
B@GetMapping(\"/welcome\")
C@GetMapping(method = RequestMethod.GET, value = \"/welcome\")
D@GetMapping(url = \"/welcome\")"
Step-by-Step Solution
Solution:
  1. Step 1: Understand @GetMapping syntax

    @GetMapping can take the URL path directly as a value in parentheses.
  2. Step 2: Identify correct usage

    @GetMapping("/welcome") is the simplest and correct syntax to map GET requests to /welcome.
  3. Final Answer:

    @GetMapping("/welcome") -> Option B
  4. Quick Check:

    Correct @GetMapping syntax = @GetMapping(\"/welcome\") [OK]
Quick Trick: Use @GetMapping("/path") for simple GET mapping [OK]
Common Mistakes:
  • Using 'url' instead of path or value
  • Overcomplicating with method attribute
  • Incorrect annotation parameters

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes