Я следовал учебному пособию FlightReservation, и теперь я не могу отобразить mysql данные в моем браузере. Отображается только заголовок таблицы. Вот код в моем jsp файле:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@page isELIgnored="false"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Display Flights</title>
</head>
<body>
<h2>Display Flights</h2>
<table>
<tr>
<th>Airlines</th>
<th>Departure City</th>
<th>Arrival City</th>
<th>Departure Time</th>
</tr>
<c:forEach items="${flights}" var="flight">
<tr>
<td>${flight.operatingAirlines}</td>
<td>${flight.departureCity}</td>
<td>${flight.arrivalCity}</td>
<td>${flight.estimatedDepartureTime}</td>
<td><a href="showCompleteReservation?flightId=${flight.id}">Select</a></td>
</tr>
</c:forEach>
</table>
</body>
</html>
Здесь мой класс FlightController:
@Controller
public class FlightController {
@Autowired
private FlightRepository flight;
@RequestMapping(value ="/findFlights")
public String findFlights(@RequestParam("from") String from, @RequestParam("to") String to,
@RequestParam("departureDate") @DateTimeFormat(pattern = "MM-dd-yyyy") Date departureDate,
ModelMap modelMap) {
List<Flight> flights = flight.findFlights(from, to, departureDate);
modelMap.addAttribute("flights", flights);
return "displayFlights";
}
}
Вот мой интерфейс flightRepository:
public interface FlightRepository extends JpaRepository<Flight, Long> {
@Query(value ="SELECT * from Flight where DEPARTURE_CITY=:departureCity and ARRIVAL_CITY=:arrivalCity and DATE_OF_DEPARTURE=:dateOfDeparture", nativeQuery = true)
List<Flight> findFlights(@Param("departureCity") String from, @Param("arrivalCity") String to,
@Param("dateOfDeparture") Date departureDate);
}
Это то, что я получил в своем браузере
Это то, что я ожидал