I am creating a Spring boot application for booking flights. I have a home page, where flight details are displayed in a table using thymeleaf as below:
<table border="solid">
<tr>
<th>Airline</th>
<th>Flight Number</th>
<th>Departure</th>
<th>Arrival</th>
<th>Date</th>
<th>Seats available</th>
<th>Price</th>
</tr>
<tr th:each="flight : ${flightList}">
<td th:text="${flight.airlineName}"></td>
<td th:text="${flight.flightNumber}" th:field="*{flightNumber}"></td>
<td th:text="${flight.departure}"></td>
<td th:text="${flight.arrival}"></td>
<td th:text="${flight.date}"></td>
<td th:text="${flight.availableSeats}"></td>
<td th:text="${flight.price}"></td>
</tr>
</table>
I am trying to fetch the specific flight using the flight number and pass it as parameter to the controller in order to display it on the next page.
@GetMapping("/booking-page")
public String getBookingPage(@RequestParam("flightNumber") String flightNumber) {
flightService.findFlightByFlightNumber(flightNumber);
return "bookFlight";
}
It is not working though. Any alternative?
New contributor
Hisham Gundagi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.