📄 neworderaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import java.sql.SQLException;
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 com.DateBean.DateBean;
/**
* MyEclipse Struts
* Creation date: 01-20-2008
*
* XDoclet definition:
* @struts.action validate="true"
* @struts.action-forward name="error" path="/error.jsp"
* @struts.action-forward name="success" path="/success.jsp"
*/
public class NewOrderAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
* @throws SQLException
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) throws SQLException {
//变量初始化
boolean status = false;
int temp = 0;
String sql="";
//实例化DateBean对象
DateBean db=new DateBean();
//用Request获得插入值
String customID =(String)request.getParameter("customID");
String employeeID =(String)request.getParameter("employeeID");
String orderDate =(String)request.getParameter("orderDate");
String sendDate =(String)request.getParameter("sendDate");
//执行数据插入
sql="insert into Orders(customID,employeeID,orderDate,sendDate,status)" +
" values('"+customID+"','"+employeeID+"','"+orderDate+"','"+sendDate+"','"+status+"')";
temp = db.executeUpdate(sql);
//插入成功返回success页面 ,否则返回出错
if(temp>0)
return mapping.findForward("success");
else
return mapping.findForward("error");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -