Complete the code to create a GET endpoint using @GetMapping.
public class HelloController { @[1]("/hello") public String sayHello() { return "Hello, world!"; } }
The @GetMapping annotation is used to map HTTP GET requests to the method.
Complete the code to specify the path for the GET request.
@GetMapping(path = "[1]") public String greet() { return "Hi!"; }
The path should start with a slash / to define the endpoint URL correctly.
Fix the error in the annotation to correctly map a GET request.
@[1]("/welcome") public String welcome() { return "Welcome!"; }
The annotation is case-sensitive and must be exactly @GetMapping.
Fill both blanks to create a GET endpoint that returns a greeting message.
public class GreetingController { @[1]([2] = "/greet") public String greet() { return "Hello!"; } }
@GetMapping is the correct annotation and value is the common attribute to specify the path.
Fill all three blanks to create a GET endpoint with a path and a method returning a string.
public class MyController { @[1]([2] = "/hello") public [3] sayHello() { return "Hello!"; } }
The method is annotated with @GetMapping using the path attribute, and the return type is String.
