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