In a Spring controller, I am performing two iterations of an Entity as shown below : Students and Course needed to be passed to the view
//this is the first iterations
List<Students> searchList = studentService.getAllStudents(splitStr[0]);
for(Students listItems : searchList){
String firstname = listItems.getFirstname();
String lastname = listItems.getLastname();
}
//this is the second iterations
List<Course> courseList = courseService.getAllCourse(splitStr[0]);
for(Course listItems : searchList2){
...
}
I can only pass one of the list to the view at the moment as shown here
return new ModelAndView("searchList", "searchList", searchList);
My challenge is to pass this list to the view as well, but I can only return one ModelAndView object
return new ModelAndView("searchList", "searchList", courseList);