📄 createflightaction.java
字号:
package action;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import org.apache.struts.action.ActionMessages;
import bean.FlightBean;
import dao.CreateFlightDao;
import orm.Flight;
public class CreateFlightAction extends Action{
private CreateFlightDao flightdao;
public ActionForward execute(ActionMapping map, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws Exception {
// TODO 自动生成方法存根
ActionMessages errors = new ActionMessages();
String flight_no = (String)((FlightBean)form).getFlight_no();
String start_place = (String)((FlightBean)form).getStart_place();
String end_place = (String)((FlightBean)form).getEnd_place();
String starttime = (String)((FlightBean)form).getstarttime();
int time = (int)((FlightBean)form).getTime();
double price = (double)((FlightBean)form).getPrice();
flight_no = new String(flight_no.getBytes("ISO-8859-1"),"GB2312");
start_place = new String(start_place.getBytes("ISO-8859-1"),"GB2312");
end_place = new String(end_place.getBytes("ISO-8859-1"),"GB2312");
starttime = new String(starttime.getBytes("ISO-8859-1"),"GB2312");
Flight flight = new Flight();
flight.setFlight_no(flight_no);
flight.setStart_place(start_place);
flight.setEnd_place(end_place);
flight.setstarttime(starttime);
flight.setTime(time);
flight.setPrice(price);
if( flightdao.ifexist(flight_no)){
errors.add("fail_1",new ActionMessage("create.b"));
saveErrors(request,errors);
return (map.getInputForward());
}
if( !flightdao.saveFlight(flight)){
errors.add("fail_1",new ActionMessage("createflight.fail"));
saveErrors(request,errors);
return (map.getInputForward());
}else{
errors.add("succeed_1",new ActionMessage("createflight.success"));
saveErrors(request,errors);
return (map.getInputForward());
}
}
public CreateFlightDao getFlightdao() {
return flightdao;
}
public void setFlightdao(CreateFlightDao flightdao) {
this.flightdao = flightdao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -