How to retrieve a list of data in spring boot without passing any variable. We are passing only URL for the GET request.
For example, in below code I am passing "roll no" and it is working fine, it is fetching corresponding student detail.
@GetMapping{"/fetch/{rollNo}")
public List<StudentDetail> findStudentDeatilbyRollNo (@PathVariable String rollNo){
return StudentService.findStudentDetailByRollNo(rollNo);
}
But when I want to fetch all student data without passing parameter it is giving me error "Non-static method 'fetchAllStudentDetail()' can not be referenced from a static context"
@GetMapping{"/allStudentDetails")
public List<StudentDetail> fetchAllStudentDeatil(){
return StudentService.fetchAllStudentDeatil();
}
Someone, please help me with the problem.