?? addproduct.java
字號:
package com.briup.admin.web.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 com.briup.admin.service.IAdminService;import com.briup.admin.web.form.AddProductForm;import com.briup.common.dao.pojo.Product;import com.briup.common.dao.pojo.ProductType; /* * 這是AddProductAction的原版本(功能類似) * 名字定義不規范(工程內沒有使用) * *//** *class AddProduct *@author briup *Date 2008-2-23 下午04:07:57 */public class AddProduct extends Action { IAdminService adminService; public void setAdminService(IAdminService adminService) { this.adminService = adminService; } public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { //通過form獲取所有的提交字段 AddProductForm addproForm = (AddProductForm)form; String productName = addproForm.getProductName(); String productTypeName = addproForm.getProductType(); Double baseFee = addproForm.getBaseFee(); Double rateFee = addproForm.getRateFee(); Long dailyLimit = addproForm.getDailyLimit(); Long monthLimit = addproForm.getMonthLimit(); Long upLimit = addproForm.getUpLimit(); Long downLimit = addproForm.getDownLimit(); Double sfee = addproForm.getSfee(); String remark = addproForm.getRemark(); //創建Product對象和ProductType對象 Product product = new Product(); ProductType proType = new ProductType(); //設置Product對象的屬性 product.setName(productName); product.setBaseFee(baseFee); product.setRateFee(rateFee); product.setDailyLimit(dailyLimit); product.setMonthLimit(monthLimit); product.setUpLimit(upLimit); product.setDownLimit(downLimit); product.setSfee(sfee); product.setRemark(remark); //設置ProductType對象的屬性 proType.setName(productTypeName); proType.setRemark(productTypeName); //將兩個對象(Product和ProductType)相關聯 product.setProductType(proType); try{ //級聯保存到數據庫 adminService.save(product); return mapping.findForward("success") ; }catch(Exception e){ e.printStackTrace(); request.setAttribute("message", "品牌增加失敗"); return mapping.findForward("failed") ; } }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -