I am trying to display my database data using spring data JPA with springboot. The following is my code, this is my controller file,
@Autowired
DriverRepository driverRepo;
@RequestMapping(value = "/dHome", method = RequestMethod.GET)
public ModelAndView driverLoad()
{
Driver driverDetails = new Driver();
driverDetails = (Driver) driverRepo.findAll();
ModelAndView model = new ModelAndView("driverhome");
return model;
}
And the following is my view file,
<c:forEach var="list" items="${driverDetails}">
<c:out value="${list.name}"/>
<c:out value="${list.age}"/>
</c:forEach>
And I am getting the result like "There was an unexpected error (type=Internal Server Error, status=500). java.util.ArrayList cannot be cast to com.central.model.Driver"