📄 createflightaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yc.struts.action;
import java.io.UnsupportedEncodingException;
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 com.yc.dao.CreateFlightDao;
import com.yc.model.Flights;
import com.yc.struts.form.FlightBeanForm;
/**
* MyEclipse Struts
* Creation date: 01-07-2009
*
* XDoclet definition:
* @struts.action path="/createFlight" name="flightBeanForm" input="/pages/CreateFlight.jsp" scope="request" validate="true"
*/
public class CreateFlightAction extends Action {
private CreateFlightDao flightdao;
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws UnsupportedEncodingException
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
FlightBeanForm flightBeanForm = (FlightBeanForm) form;// TODO Auto-generated method stub
ActionMessages errors=new ActionMessages();
String flight_no=(String)flightBeanForm.getFlight_no();
String start_place=(String)flightBeanForm.getStart_place();
String end_place=(String)flightBeanForm.getEnd_place();
Integer time=(Integer)flightBeanForm.getTime();
double price=(Double)flightBeanForm.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");
//创建一个航空实体对象,把从航班模型读取出来的数据保存到该对象中
Flights flight=new Flights();
flight.setFlightNo(flight_no);
flight.setStartPlace(start_place);
flight.setEndPlace(end_place);
flight.setTime(time);
flight.setPrice(price);
if(!flightdao.saveFlight(flight)) //调用航班实体DAO,保存航班对象
{
errors.add("fail",new ActionMessage("Create flight fail"));
saveErrors(request,errors);
return (mapping.getInputForward());
}
else
{
errors.add("sucess",new ActionMessage("Create flight sucess"));
saveErrors(request,errors);
return (mapping.getInputForward());
}
}
public CreateFlightDao getFlightdao()
{
return this.flightdao;
}
public void setFlightdao(CreateFlightDao flightdao)
{
this.flightdao=flightdao;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -