neworderaction.java

来自「主要是用于一个订货的系统.分为几层。。较好的区分的类别」· Java 代码 · 共 64 行

JAVA
64
字号
/*
 * 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 + =
减小字号Ctrl + -
显示快捷键?