|
|
|
@ -41,7 +41,7 @@ public class search_fly extends HttpServlet {
|
|
|
|
|
String sql = null;
|
|
|
|
|
|
|
|
|
|
if (departure.isEmpty() && destination.isEmpty() && departureYear.isEmpty() && departureMonth.isEmpty() && departureDay.isEmpty()) {
|
|
|
|
|
// 如果所有字段都为空,重定向到原页面
|
|
|
|
|
// 濡傛灉鎵<EFBFBD>鏈夊瓧娈甸兘涓虹┖锛岄噸瀹氬悜鍒板師椤甸潰
|
|
|
|
|
resp.sendRedirect(url);
|
|
|
|
|
} else {
|
|
|
|
|
sql = "SELECT * FROM flight WHERE 1=1";
|
|
|
|
@ -53,7 +53,7 @@ public class search_fly extends HttpServlet {
|
|
|
|
|
sql += " AND f_a_p='" + destination + "'";
|
|
|
|
|
}
|
|
|
|
|
if (!departureYear.isEmpty() && !departureMonth.isEmpty() && !departureDay.isEmpty()) {
|
|
|
|
|
// 验证日期格式
|
|
|
|
|
// 楠岃瘉鏃ユ湡鏍煎紡
|
|
|
|
|
try {
|
|
|
|
|
int year = Integer.parseInt(departureYear);
|
|
|
|
|
int month = Integer.parseInt(departureMonth);
|
|
|
|
@ -62,10 +62,10 @@ public class search_fly extends HttpServlet {
|
|
|
|
|
String departureDate = String.format("%04d-%02d-%02d", year, month, day);
|
|
|
|
|
sql += " AND DATE(f_Date)='" + departureDate + "'";
|
|
|
|
|
} else {
|
|
|
|
|
req.setAttribute("errorMsg", "日期格式不正确,请输入有效的年、月、日");
|
|
|
|
|
req.setAttribute("errorMsg", "鏃ユ湡鏍煎紡涓嶆纭紝璇疯緭鍏ユ湁鏁堢殑骞淬<EFBFBD>佹湀銆佹棩");
|
|
|
|
|
}
|
|
|
|
|
} catch (NumberFormatException e) {
|
|
|
|
|
req.setAttribute("errorMsg", "日期格式不正确,请输入数字");
|
|
|
|
|
req.setAttribute("errorMsg", "鏃ユ湡鏍煎紡涓嶆纭紝璇疯緭鍏ユ暟瀛<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -84,11 +84,15 @@ public class search_fly extends HttpServlet {
|
|
|
|
|
flight_info.setF_s_t(res.getString(6));
|
|
|
|
|
flight_info.setF_a_t(res.getString(7));
|
|
|
|
|
flight_info.setF_p(res.getString(8));
|
|
|
|
|
flight_info.setF_d(res.getString(9));
|
|
|
|
|
flight_info.setF_delay(res.getString(10));
|
|
|
|
|
flight_info.setF_food(res.getString(11));
|
|
|
|
|
flight_info.setF_wide(res.getString(12));
|
|
|
|
|
flightlist.add(flight_info);
|
|
|
|
|
}
|
|
|
|
|
req.setAttribute("flightlist", flightlist);
|
|
|
|
|
} catch (SQLException e) {
|
|
|
|
|
System.out.println("错误信息:" + e);
|
|
|
|
|
System.out.println("閿欒淇℃伅锛<EFBFBD>" + e);
|
|
|
|
|
} finally {
|
|
|
|
|
conn.closeDB();
|
|
|
|
|
}
|
|
|
|
|