posts - 188,comments - 176,trackbacks - 0

           

          最近做畢設,將自己以前寫的一個購物車的模塊重構了一遍,將一些bug進行了修復。實現了對hashmap容器的基本CRUD功能。在這里和大家一起分享下,希望大家提出更好意見和想法。

          原理:利用session會話保持用戶一次購物操作的購買記錄,當用戶點擊“結帳”后將保存在session中的hashmap容器中的信息insert到DB中,完成一次購物操作。

          模塊所需要配置文件:hibernate.cfg.xml  ,TableGoods.hbm.xml  ,struts-config.xml 

          模塊對應的jsp有:index.jsp(商品信息一覽頁面),buy.jsp(購買操作后的商品清單頁面)

          模塊對應的action有:IndexAction (實現對DB中的商品表信息結果集的遍歷,并轉向對應的index.jsp) 
                                               ListAction (將JSP上的商品信息存入hashmap容器,并轉向對應的buy.jsp)
                                               UpdateAction (對buy.jsp頁面上的商品數量修改的業務邏輯處理)
                                               DeleteAction (對buy.jsp頁面上的商品列表信息的業務邏輯處理)

          模塊所需的相關Java容器選擇:存儲商品id,sum,price,name,allprices信息用hashmap,主要是考慮到其key重復后可以覆蓋上次的value記錄。存儲點擊商品后的商品id用list容器,主要考慮到list是有序并可以重復的特點,用其可以跟蹤用戶多次點擊相同商品的操作,并對商品的數量進行相應的增加。

          模塊主要Action類如下:

           /** 
            * 陳列商品
            
          */


          IndexAction:

          public class IndexAction extends Action {

           
          public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
            
            
          //查找商品表中的所有商品信息
               GoodsDAO dao = new GoodsDAO();
            List list 
          = dao.find();
            request.setAttribute(
          "lister",list);
            
            
          return mapping.findForward("a");
           }

          }



          /** 
            * 點擊購買信息
            
          */


          ListAction:

          public class ListAction extends Action {

           
          // 將hashmap中value轉到list中
           public static List getList(HashMap hs) {
            List list 
          = new ArrayList();
            Iterator itr 
          = hs.keySet().iterator();
            
          while (itr.hasNext()) {
             list.add(hs.get(itr.next()));
             }

            
          return list;
           }

          //優化后的getList方法
           public static List getList(HashMap hs) {
            
          return new ArrayList(hs.values());
           }



           
          // 將點擊的商品id和已經點擊過的商品id數組中去比較,看是否有重復,真為有重復
           public static boolean isCheck_on(int[] ids, int _id) {
            
          boolean flag = false;
            
          for (int i = 0; i < ids.length; i++{
             
          if (ids[i] == _id) {
              flag 
          = true;
             }

            }

            
          return flag;
           }


           
          // 將新點擊商品的id和list(存放在session中的allIdSumList容器)中元素的id屬性比較
           public static void test_ListCheck(List list, int check_id, float _p,String _n) {
            
          for (int i = 0; i < list.size(); i++{
             
          int j = ((IdSumPriceNameDTO) list.get(i)).getId();
             
          // 將list_sumId的第i個元素++
             int k = ((IdSumPriceNameDTO) list.get(i)).getSum();
             
          if (j == check_id) {
             
          //相等條件則將k(商品數量)++
              k++;
             
          //session中的"allIdSumList"也隨之更新,引用傳參原理
              ((IdSumPriceNameDTO) list.get(i)).setSum(k);
              
          //list.remove(i);
              
          //IdSumPriceNameDTO idSumDTO = new IdSumPriceNameDTO(j, k, _p,_n);
              
          //將更新后的idSumDTO重新add到list中,session中的"allIdSumList"也隨之更新,引用傳參原理
              
          //list.add(i, idSumDTO);
             }

            }

           }

           
           
          // 將點擊商品id和allIdSumList(session中)比較,并返回比較后的list_sumId
           public static List getCounter_List(List _list_check, int id, HttpSession sess,
             
          float price,String _name) {

            List list_sumId 
          = null;
            String flag 
          = (String) sess.getAttribute("flags");
            
          // 執行了修改操作的條件
            if (flag != null{
             
          // 從session中獲得已經修改過商品的id的數組
             int[] ider = (int[]) sess.getAttribute("ider");
             
          // 在修改操作后,在已修改商品上繼續購物操作
             if (isCheck_on(ider, id)) {
               list_sumId 
          = (List) sess.getAttribute("allIdSumList");
             
          // 調用test_ListCheck方法
               test_ListCheck(list_sumId,id,price,_name);
              }
           
             
          // 修改操作后,點擊沒有被修改數量過的商品
             else {
             
          // 標志位
              boolean flag_c = true;
              
          // 新點擊商品id和list中歷史點擊記錄比較
              for (int i = 0; i < _list_check.size() - 1; i++{
               
          if (_list_check.get(i).equals(id)) {
                flag_c 
          = false;
               }

              }

               
          // session中獲得"allIdSumList"
              list_sumId = (List) sess.getAttribute("allIdSumList");
               
          // 新點擊操作
              if(flag_c){
               IdSumPriceNameDTO idSumDTO 
          = new IdSumPriceNameDTO(id, 1, price,_name);
              
          // session中的"allIdSumList"也隨之更新,引用copy
               list_sumId.add(idSumDTO);
               }

               
          // 重復點擊操作
              else{
               
          // 調用test_ListCheck方法
               test_ListCheck(list_sumId,id,price,_name);
              }

             }

            }

               
          // 未點擊修改的操作條件
            else {
             
          // session中獲得"allIdSumList"
             list_sumId = (List) sess.getAttribute("allIdSumList");
             
          // 標志位
             boolean flag_c = true;
             
          // 新點擊商品id和list中歷史點擊記錄比較
             for (int i = 0; i < _list_check.size() - 1; i++{
              
          if (_list_check.get(i).equals(id)) {
               flag_c 
          = false;
              }

             }

             
          // 新點擊操作
             if (flag_c) {
              IdSumPriceNameDTO idSumDTO 
          = new IdSumPriceNameDTO(id, 1, price,_name);
             
          // session中的"allIdSumList"也隨之更新,引用copy
              list_sumId.add(idSumDTO);
             }

             
          // 重復點擊操作
             else {
               
          // 調用test_ListCheck方法
               test_ListCheck(list_sumId,id,price,_name);
             }

            }

            
          return list_sumId;
           }



           
          public ActionForward execute(ActionMapping mapping, ActionForm form,
             HttpServletRequest request, HttpServletResponse response)
             
          throws Exception {
            
          // 商品編號
            int id = Integer.parseInt(request.getParameter("id"));
            GoodsDAO dao 
          = new GoodsDAO();
            
          int goodsid = dao.findbyId(id).getId();
            String goodsName 
          = dao.findbyId(id).getGoodsName();
            
          float goodsPrice = (float) dao.findbyId(id).getGoodsPrice();
            
          //set進idSumDTO 
            IdSumPriceNameDTO idSumDTO = new IdSumPriceNameDTO();
            idSumDTO.setId(goodsid);
            idSumDTO.setGoodsName(goodsName);
            idSumDTO.setGoodsPrice(goodsPrice);
            
          // idSumDTO中的sum屬性缺省為1
            idSumDTO.setAllPrices(goodsPrice);
            System.out.println(idSumDTO.getAllPrices());
            
            
          // hid做為hashmap中的key
            Integer hid = Integer.valueOf(idSumDTO.getId());
            
            HttpSession sess 
          = request.getSession();
            HashMap hs 
          = (HashMap) sess.getAttribute("shops");

            
          /** *//**
             * 客戶第一次訪問
             
          */

            
          if (hs == null{
             
          //將商品id放入list中
             List list = new ArrayList();
             list.add(hid);
             hs 
          = new HashMap();
             hs.put(hid, idSumDTO);
             
          // jsp顯示
             sess.setAttribute("shop", getList(hs));
             
          // 將hs放到session中,刪除修改用
             sess.setAttribute("shops", hs);
             
          // 將list(商品id)放入session中
             sess.setAttribute("ids_go", list);
             
          // 將商品id,sum,price,name放入idSumDTO_1并置于idSum_list中
             IdSumPriceNameDTO idSumDTO_1 = new IdSumPriceNameDTO(idSumDTO.getId(), idSumDTO
               .getSum(), idSumDTO.getGoodsPrice(),idSumDTO.getGoodsName());
             List idSum_list 
          = new ArrayList();
             idSum_list.add(idSumDTO_1);
             
          // 將idSum_list對象至于sess中,和updateAction中的"allIdSumList"對應
             sess.setAttribute("allIdSumList", idSum_list);
            }

            
          /** *//**
             * 客戶第二次以后的訪問
             
          */

            
          else {
             List list_check 
          = (List) sess.getAttribute("ids_go");
             list_check.add(hid);
             
          // list_sumId包含id,sum,price,name
              List list_sumId = getCounter_List(list_check, hid, sess, goodsPrice,goodsName);
             
          for (int i = 0; i < list_sumId.size(); i++{
              IdSumPriceNameDTO isp 
          = new IdSumPriceNameDTO();
              
          int a = ((IdSumPriceNameDTO) list_sumId.get(i)).getId();
              isp.setId(a);
              
          int b = ((IdSumPriceNameDTO) list_sumId.get(i)).getSum();
              isp.setSum(b);
              
          float c = ((IdSumPriceNameDTO) list_sumId.get(i)).getGoodsPrice();
              isp.setGoodsPrice(c);
              isp.setAllPrices(c);
              String d  
          =((IdSumPriceNameDTO) list_sumId.get(i)).getGoodsName();
              isp.setGoodsName(d);
              
          //session中的shops也隨之更新,引用copy
              hs.put(a, isp);
              
          //引用賦null
              isp = null;
             }

             
          // jsp顯示
             sess.setAttribute("shop", getList(hs));
            }

            
          //轉向buy.jsp
            return mapping.findForward("b");
           }


          }



          UpdateAction:

            
          /** 
            * 修改商品信息
            
          */


          public class UpdateAction extends Action {

           
          //優化后的getList方法
           public static List getList(HashMap hs) {
            
          return new ArrayList(hs.values());
           }


           
          public ActionForward execute(ActionMapping mapping, ActionForm form,
             HttpServletRequest request, HttpServletResponse response)
             
          throws Exception {
            GoodsForm gs 
          = (GoodsForm)form;
            
          int[] ids = gs.getId();
            
          int[] sums = gs.getSum();
            
          float[] goodsPrices = gs.getGoodsPrice();
            String[] goodsName 
          = gs.getGoodsName();
            
          //從session獲得hs
            HashMap hs = (HashMap)request.getSession().getAttribute("shops");
            
          //從session中獲得allIdSumList容器
            List idSum_list = (List)request.getSession().getAttribute("allIdSumList");
            
          //清空上次idSum_list容器中更新后的記錄
            if(idSum_list!=null){
             idSum_list.clear();
            }

            
          for(int i = 0;i<ids.length;i++){
             
          //循環將 ids[i]和idSumPriceNameDTO put到hs容器中
             IdSumPriceNameDTO idSumPriceNameDTO = new IdSumPriceNameDTO();
             idSumPriceNameDTO.setId(ids[i]);
             idSumPriceNameDTO.setGoodsName(goodsName[i]);
             idSumPriceNameDTO.setGoodsPrice(goodsPrices[i]);
             idSumPriceNameDTO.setSum(sums[i]);
             idSumPriceNameDTO.setAllPrices(goodsPrices[i]);
             
          // session中的"shops"也隨之更新,引用copy
             hs.put(ids[i], idSumPriceNameDTO);
             
          //每次循環后將idSumPriceNameDTO 的引用設null
             idSumPriceNameDTO = null;

             
          //idSum_list
             IdSumPriceNameDTO idSumDTO = new IdSumPriceNameDTO(ids[i],sums[i],goodsPrices[i],goodsName[i]);
             
          if(idSum_list == null){
              idSum_list 
          = new ArrayList();
             }

             
          // session中的"allIdSumList"也隨之更新,引用copy
             idSum_list.add(idSumDTO);
            }

            request.getSession().setAttribute(
          "shop", getList(hs));
            
               
          // 將過到updateAction中的商品id數組放入session中對修改操作完成后用戶繼續點擊操作時和ider數組記錄比較
               request.getSession().setAttribute("ider", ids);
               
          // 設置一個標志位,標志是經過修改數量的操作
               String flag = "update";
               request.getSession().setAttribute(
          "flags", flag);
            
          //轉向buy.jsp
            return mapping.findForward("b");
           }


          }



          DeleteAction:

            
          /** 
            * 刪除商品信息
            
          */


          public class DeleteAction extends Action {


          //優化后的getList方法
           public static List getList(HashMap hs) {
            
          return new ArrayList(hs.values());
           }


           
          public ActionForward execute(ActionMapping mapping, ActionForm form,
             HttpServletRequest request, HttpServletResponse response)
             
          throws Exception {

            Integer id 
          = Integer.parseInt(request.getParameter("id"));

            
          // 將ids_go中點擊Id的歷史記錄中與頁面傳來的id比較,將相同的元素全delete掉
            List list_check = (List) request.getSession().getAttribute("ids_go");
            
          int size = list_check.size();
            
          int h = 0;
            
          for (int i = 0; i < size; i++{
             
          int j = (Integer)list_check.get(h);
             
          if (j == id) {
              
          //session中的"ids_go"也隨之更新,引用copy
              list_check.remove(h);
             }
          else{
              h
          ++;
             }

            }

             
          // remove容器allIdSumList中和id相等的整個元素,保持delete后繼續購物操作的正確性
            List list = (List) request.getSession().getAttribute("allIdSumList");
            
          for (int i = 0; i < list.size(); i++{
             
          int j = ((IdSumPriceNameDTO) list.get(i)).getId();
             
          if (j == id) {
             
          //session中的"allIdSumList"也隨之更新,引用copy
              list.remove(i);
             }

            }

            
          // 從session中取出購物的hashmap容器
            HashMap hashmap = (HashMap) request.getSession().getAttribute("shops");
            
          //session中的shops也隨之更新,引用copy
            hashmap.remove(id);
            
          //jsp顯示
            request.getSession().setAttribute("shop", getList(hashmap));
            
            
          //執行了delete操作后,將updateAction中的標記flag設置為null
            
          //delete后,將修改信息的標記去除,還原為無修改操作狀態
            String flag = null;
            request.getSession().setAttribute(
          "flags", flag);
            
          //轉向buy.jsp
            return mapping.findForward("b");
           }


          }



          IdSumPriceNameDTO :

          public class IdSumPriceNameDTO {

           
          private int id;

           
          private int sum = 1;

           
          private float goodsPrice;
           
           
          private float allPrices;
           
           
          private String goodsName;

           
          public IdSumPriceNameDTO() {
            
          super();
           }

           
          //id,sum,goodsPrice,goodsName
           public IdSumPriceNameDTO(int id, int sum, float goodsPrice, String goodsName) {
            
          super();
            
          this.id = id;
            
          this.sum = sum;
            
          this.goodsPrice = goodsPrice;
            
          this.goodsName = goodsName;
           }


           
          public String getGoodsName() {
            
          return goodsName;
           }


           
          public void setGoodsName(String goodsName) {
            
          this.goodsName = goodsName;
           }



           
          public float getAllPrices() {
            
          return allPrices;
           }

           
          //注意javabean中set 只有一個參數,定義多個時到jsp頁面會出現無法找到getProperty異常
           public void setAllPrices(float goodsPrice) {
            
          this.allPrices = (float)(this.sum * goodsPrice);
           }

           

           
          public float getGoodsPrice() {
            
          return goodsPrice;
           }


           
          public void setGoodsPrice(float goodsPrice) {
            
          this.goodsPrice = goodsPrice;
           }


           
          public int getId() {
            
          return id;
           }


           
          public void setId(int id) {
            
          this.id = id;
           }


           
          public int getSum() {
            
          return sum;
           }


           
          public void setSum(int sum) {
            
          this.sum = sum;
           }


          }



          GoodsForm :

          public class GoodsForm extends ActionForm {

              
          //商品名稱數組
              private String[] goodsName;
              
              
          //商品id數組
              private int[] id;    
              
              
          //數量數組
              private int[] sum;
              
                  
          //價格數組
              private float[] goodsPrice;
                      
              
          public float[] getGoodsPrice() {
                  
          return goodsPrice;
              }


              
          public void setGoodsPrice(float[] goodsPrice) {
                  
          this.goodsPrice = goodsPrice;
              }


              
          public int[] getId() {
                  
          return id;
              }


              
          public void setId(int[] id) {
                  
          this.id = id;
              }


              
          public int[] getSum() {
                  
          return sum;
              }


              
          public void setSum(int[] sum) {
                  
          this.sum = sum;
              }


              
          public String[] getGoodsName() {
                  
          return goodsName;
              }


              
          public void setGoodsName(String[] goodsName) {
                  
          this.goodsName = goodsName;
              }


              
              
          }



          buy.jsp:

          <%@ page language="java" contentType="text/html; charset=UTF-8"
           pageEncoding
          ="UTF-8"
          %>
          <%@ taglib uri="WEB-INF/struts-bean.tld" prefix="bean"%>
          <%@ taglib uri="WEB-INF/struts-html.tld" prefix="html"%>
          <%@ taglib uri="WEB-INF/struts-logic.tld" prefix="logic"%>
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html:html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <title></title>
          </head>
          <body bgcolor="#CCCCCC">
          <html:form action="/update">
          <html:submit value="update" />
          <table width="302" height="55" border="1">
           
          <tr>
               
          <td width="59">DELETE</td>
            
          <td width="68">NAME</td>
            
          <td width="77">PRICE</td>
            
          <td width="77">NUM</td>
            
          <td width="77">ALLPRICE</td>
           
          </tr>
           
          <logic:iterate id="sh" name="shop">
           
          <tr>
              
          <html:hidden  name="sh"  property="id" />
              
          <html:hidden  name="sh"  property="goodsPrice" />
              
          <html:hidden  name="sh"  property="goodsName" />
              
          <td><html:link  page="/delete.do" paramId="id" paramName="sh" paramProperty="id" >delete</html:link></td>
              
          <td><bean:write name="sh" property="goodsName" /></td>
              
          <td><bean:write name="sh" property="goodsPrice" /></td>
              
          <td><html:text  name="sh"  property="sum" /></td>
              
          <td><bean:write name="sh" property="allPrices" /></td>
           
          </tr>   
           
          </logic:iterate>
          </table>
          </html:form>
          <html:link page="/shop.do">去收銀臺</html:link><html:link page="/index.do">繼續購物</html:link>

          </body>
          </html:html>


          index.jsp:

          <%@ page language="java" contentType="text/html; charset=UTF-8"
              pageEncoding
          ="UTF-8"
          %>
          <%@ taglib uri="WEB-INF/struts-bean.tld" prefix="bean"%>
          <%@ taglib uri="WEB-INF/struts-html.tld" prefix="html"%>
          <%@ taglib uri="WEB-INF/struts-logic.tld" prefix="logic"%>
          <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
          <html:html>
          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
          <title></title>
          </head>
          <body  bgcolor="#CCCCCC">
          <table width="315" border="1">
            
          <tr>
               
          <td colspan="2"><img src="1140438022_min.jpg" width="160" height="120"></td>
               
          <td colspan="2"><img src="1140437663_min.jpg" width="160" height="120"></td>
               
          <td colspan="2"><img src="1140438022_min.jpg" width="160" height="120"></td>
            
          </tr>
            
          <logic:iterate id="list" name="lister">
              
          <tr>
                
          <td><bean:write name="list" property="id" /></td>
                
          <td width="85"><html:link page="/list.do" paramId="id" paramName="list" paramProperty="id" >在線訂購</html:link></td>
              
          </tr>
            
          </logic:iterate>
          </table>

          </body>
          </html:html>


          模塊主要是圍繞hashmap容器和list容器編程,并用session會話保持整個操作的記錄,其中需要注意的一些問題總結如下:
                 
                  (1)用戶沒有進行修改操作時,點擊一件商品后,繼續購物,點擊相同商品時sum++控制。 

                  (2)用戶沒有進行修改操作時,點擊一件商品后,繼續購物,點擊新商品時sum=1控制。

                  (3)用戶沒有進行修改操作時,delete某件商品信息清單時,注意將allIdSumList容器(在session范圍內)中元素的id屬性對應的整個元素刪除操作,并將“ids_go”(session范圍內)中和此次delete操作帶的商品id比較,將相同的id在“ids_go”(list容器)中全部刪除,保證用戶成功執行delete操作,返回繼續購物時還原為初始狀態。

                  (4)用戶進行修改操作時,將allIdSumList容器中的元素屬性sum和allprices保持同步更新,并設置一個標志位flag="update",標志是經過修改數量的操作,同時當修改操作后繼續在進行修改操作時將idSum_list中的數據clear(),保證下次修改時是全新的數據,主要原因是考慮到list對于重復的元素沒有覆蓋功能。

                  (5)用戶進行刪除操作后,將updateAction中的標記flag設置為null(flag用來標記用戶是否有過update操作,session范圍內有效)


          posted on 2007-05-24 21:14 cheng 閱讀(2031) 評論(16)  編輯  收藏 所屬分類: StrutsSpringHibernate

          FeedBack:
          # re: Struts+Hibernate實現shopcart
          2007-05-25 09:31 | Web 2.0 技術資源
          頭都大了~~
          // 將hashmap中value轉到list中
          public static List getList(HashMap hs) {
          List list = new ArrayList();
          Iterator itr = hs.keySet().iterator();
          while (itr.hasNext()) {
          list.add(hs.get(itr.next()));
          }
          return list;
          }

          return new ArrayList( hs.keySet() );
          就可以了撒,多麻煩的。  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 09:41 | cheng
          先謝了~:P
          return new ArrayList( hs.keySet() );其返回的list容器中存儲的hs中的key值的集合啊,不是value哦~
            回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 09:59 | Web 2.0 技術資源
          看錯意圖了~ 這樣就OK了~
          return new ArrayList( hs.values() );  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 10:20 | cheng
          恩,謝了哦。
          代碼優化多了~!:P  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 10:21 | Web 2.0 技術資源
          你應該對 collection 框架還不夠熟悉~ 加強下就OK了~  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 10:22 | cheng
          恩~好的!謝謝!看來得好好補下集合類的一些用法了~希望以后能夠多多交流學習哦。  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 17:01 | 龍卷風驛站
          action直接調用dao ?

          服了  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart[未登錄]
          2007-05-25 19:16 | cheng
          樓上的朋友如果是考慮到代碼應該分離開來的話,可以理解~~~
          有什么好的修改意見可以提出來`一起討論下~!  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-25 20:54 | Web 2.0 技術資源
          做個服務層吧~
          把業務邏輯集中到 Service

            回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-26 01:16 | 三告習習
          還可以試試 commons-collections  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-05-29 10:47 | wuchuanzi
          嘻嘻,不錯的案例,早看到就好了,讓學生們看看  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-10-15 02:41 | iverson
          我想請問我是用Vector 做的,可以嗎?
          好象有問題!!
          盼解答  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-10-15 03:18 | iverson
          怎么沒有GoodsFrom啊?  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-10-17 17:48 | cheng
          不好意思,最近在出差,有些忙,才看到。

          list容器,主要考慮到list是有序并可以重復的特點,用其可以跟蹤用戶多次點擊相同商品的操作,并對商品的數量進行相應的增加。


          至于Vector容器,只要能實現你的具體的業務邏輯的都是可以的,主要看你的需求是怎么樣的了~~~  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-11-12 21:14 | gbk2312
          能順便將GoodsForm里和建表的SQL語句貼出來么?謝謝  回復  更多評論
            
          # re: Struts+Hibernate實現shopcart
          2007-11-17 22:48 | 任逍遙
          我支持你.我最愛源碼了.  回復  更多評論
            
          主站蜘蛛池模板: 新和县| 青田县| 哈尔滨市| 平湖市| 钟山县| 项城市| 延安市| 抚顺县| 万宁市| 麻栗坡县| 兴城市| 麟游县| 尼木县| 昭通市| 乌兰县| 清镇市| 高陵县| 双桥区| 永顺县| 惠安县| 当阳市| 绍兴县| 山西省| 芮城县| 当雄县| 洪江市| 舒兰市| 昂仁县| 安丘市| 托克逊县| 邻水| 凌源市| 潞西市| 乌审旗| 汉寿县| 浪卡子县| 宁蒗| 突泉县| 穆棱市| 顺昌县| 济南市|