Hi, need help, the site is not finding city and date information. Why
@Controller @RequestMapping("/secondSubPage") public class secondSubPageController { private static List<Travel> travels = new ArrayList<>(); public static void main(String[] args) { Travel Wroclaw = new Travel("Wroclaw", "01-02-2001"); Travel Krakow = new Travel("Kraków", "01-02-2001"); Travel JeleniaGora = new Travel("Jelenia Góra", "01-02-2001"); Travel Zgorzelec = new Travel("Zgorzelec", "01-02-2001"); Travel Luban = new Travel("Lubań", "01-02-2001"); Travel Lodz = new Travel("Lódz", "01-02-2001"); Travel Karpacz = new Travel("Karpacz", "01-02-2001"); Travel ZielonaGora = new Travel("Zielona Góra", "01-02-2001"); Travel Katowice = new Travel("Katowice", "01-02-2001"); Travel Miedzyzdroje = new Travel("Miedzyzdroje", "01-02-2001"); travels.add(Wroclaw); travels.add(Krakow); travels.add(JeleniaGora); travels.add(Zgorzelec); travels.add(Luban); travels.add(Lodz); travels.add(Karpacz); travels.add(ZielonaGora); travels.add(Katowice); travels.add(Miedzyzdroje); SpringMvcApplication.run(secondSubPageController.class, args); } private Travel findTravel(String city){ for (Travel e : travels){ if (e.getCity().equals(city)){ return e; } } return null; } @GetMapping() public List<Travel> getTravels(){ return travels; } @GetMapping("/city") public Travel getTravelCity(@RequestParam(value = "city") String city) { return findTravel(city); } @GetMapping("/date") public List<Travel> getTravelDate(){ return null; } @GetMapping("/cityAndDate") public Travel getTravelCityAndDate(@RequestParam(value = "city") String city, @RequestParam(value = "date") String date){ return findTravelCityAndDate(city, date); } private Travel findTravelCityAndDate(String city, String date){ for (Travel e : travels){ if (e.getCity().equals(city) && e.getDate() == date){ return e; } } return null; } }
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <p th:text="'Data: ' + ${date}" /> <p th:text="'Miasto: ' + ${city}" /> </p> <table> <tr> <th>City</th> <th>Date</th> </tr> <tr> <td><p th:text="${city}"/></td> </tr> <tr> <td><p th:text="${date}"/></td> </tr> </table> </body> </html>
![]()