I am trying to use a RequestMapper and GetMapper to display a Java list using Spring Boot.
@RestController
@RequestMapping(path = "api/v1/student")
public class StudentController {
@GetMapping()
List<Student> getStudents() {
return List.of (
new Student (
1L,
"Joe",
22,
LocalDate.of(2001, Month.AUGUST, 15),
"[email protected]"
)
);
}
}
This code block should display the student's information, however, when I run the Spring server (localhost:8080/api/v1/student), I am lead to a Whitelabel Error Page. Why are the mappers not getting and displaying my data?
It looks like your path may be set up wrong. Try replacing
with
and replace
with
Then you can visit
localhost:8080/api/v1/student/and it should work correctly.