0
0
Spring Bootframework~10 mins

@GetMapping for GET requests in Spring Boot - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a GET endpoint using @GetMapping.

Spring Boot
public class HelloController {
    @[1]("/hello")
    public String sayHello() {
        return "Hello, world!";
    }
}
Drag options to blanks, or click blank then click option'
AGetMapping
BDeleteMapping
CRequestMapping
DPostMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @PostMapping instead of @GetMapping
Forgetting the annotation entirely
2fill in blank
medium

Complete the code to specify the path for the GET request.

Spring Boot
@GetMapping(path = "[1]")
public String greet() {
    return "Hi!";
}
Drag options to blanks, or click blank then click option'
A/Greet
B/greet
Cgreet
Dgreet/
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the leading slash
Using uppercase letters in path inconsistently
3fill in blank
hard

Fix the error in the annotation to correctly map a GET request.

Spring Boot
@[1]("/welcome")
public String welcome() {
    return "Welcome!";
}
Drag options to blanks, or click blank then click option'
AGetMapping
BGetmapping
CPostMapping
DRequestMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase letters in annotation name
Using @PostMapping by mistake
4fill in blank
hard

Fill both blanks to create a GET endpoint that returns a greeting message.

Spring Boot
public class GreetingController {
    @[1]([2] = "/greet")
    public String greet() {
        return "Hello!";
    }
}
Drag options to blanks, or click blank then click option'
AGetMapping
Bpath
Cvalue
DPostMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @PostMapping instead of @GetMapping
Using an incorrect attribute name
5fill in blank
hard

Fill all three blanks to create a GET endpoint with a path and a method returning a string.

Spring Boot
public class MyController {
    @[1]([2] = "/hello")
    public [3] sayHello() {
        return "Hello!";
    }
}
Drag options to blanks, or click blank then click option'
AGetMapping
Bpath
CString
DPostMapping
Attempts:
3 left
💡 Hint
Common Mistakes
Using @PostMapping instead of @GetMapping
Using 'value' instead of 'path' attribute
Wrong return type