문제

I want to pass a List of objects to one of my functions.

Here's the code:

@RequestMapping(value = "/pages/generateReports")
public ModelAndView toGenerateReports(@ModelAttribute("forReports") @Valid Reports report){    

    List<Patients> patients = patientsDAO.listAllPatients(report.getDateFrom(), report.getDateTo());

    //tried printing what's in patients and surely it contains something

    GenerateReports reports = new GenerateReports();
    reports.generateReports(patients);

    return ...;
}

public class GenerateReports {
    public void generateReports(List<? extends Patients> patients) {

    ....some checkings here and all I get is an empty list... 

    }
}

What do I have to do to make it work?

도움이 되었습니까?

해결책

Your code looks good to me, it should work. You can change List<? extends Patients> patients to List<Patients> patients but that should not change anything.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top