📄 foodaddaction.java
字号:
package com.food.web.action;
import org.apache.struts.action.ActionForward;
import com.common.struts.*;
import com.common.*;
import com.food.dao.FoodDao;
import com.food.form.Food;
public class FoodAddAction extends AbstractAction {
public FoodAddAction() {
}
public ActionForward execute(ActionContext actionContext) throws java.lang.Exception {
SessionContext ctx = (SessionContext) actionContext.getSession().getAttribute(Globals.SESSION_CONTEXT);
String storeID = ctx.getStoreID();
String foodID = actionContext.getParameter("foodID");
String foodName = actionContext.getParameter("foodName");
String foodType = actionContext.getParameter("foodType");
String sbigPrice = actionContext.getParameter("bigPrice");
float bigPrice=0.0f;
if(!(("").equals(sbigPrice) || sbigPrice==null))
bigPrice = Float.parseFloat(sbigPrice);
float smallPrice = 0.0f;
String sSmallPrice = actionContext.getParameter("smallPrice");
if(!(("").equals(sSmallPrice) || sSmallPrice==null))
smallPrice = Float.parseFloat(sSmallPrice);
float snackPrice = 0.0f;
String sSnackPrice = actionContext.getParameter("snackPrice");
if(!(("").equals(sSnackPrice) || sSnackPrice==null))
snackPrice = Float.parseFloat(sSnackPrice);
String descript = actionContext.getParameter("descript");
String foodImage = actionContext.getParameter("foodImage");
String foodClass = actionContext.getParameter("foodClass");
Food info = new Food(foodID,foodName,foodType,bigPrice, smallPrice,snackPrice,descript,foodImage,foodClass,storeID);
FoodDao dao = new FoodDao();
dao.inserFoodToDb(info);
return actionContext.getMapping().findForward("foodAdd");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -