Look at the controller class:
Java
@RestController("/lines")
public class LinesController {
private List<String> strings;
public LinesController() {
strings = new ArrayList<>();
strings.add("zero line");
strings.add("first line");
strings.add("second line");
}
@GetMapping("/{id}")
public String getLine(@PathVariable int id){
return strings.get(id);
}
}
and the response that a user got from it:
"second line"
Kotlin
@RestController("/lines")
class LinesController {
private val strings = listOf("zero line", "first line", "second line")
@GetMapping("/{id}")
fun getLine(@PathVariable id: Int): String {
return strings[id]
}
}
and the response that a user got from it:
"second line"
Guess which of the following requests has been given to a server: