⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 showgwc_old.jsp

📁 CEBI电子商务网站 基于JSP+javaBean结构
💻 JSP
字号:
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="includesp.jsp" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'showgwc.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>

   <%

        request.setCharacterEncoding("utf-8");
        String action=request.getParameter("action");
        
        if(action != null)
        {
            String strItemNum=request.getParameter("itemnum");

            int itemNum=Integer.parseInt(strItemNum);
            for(int i=0;i<itemNum;i++)
            {
                String sm=request.getParameter("num_"+i);
                String strSpId=request.getParameter("sp_"+i);
                
                int quantity=Integer.parseInt(sm);
                int id=Integer.parseInt(strSpId);
                
                //库存
                boolean isSl=dosp.isSl(id,quantity);
                if(isSl)
                {   
                    gwc.setSpSl(new Integer(id),quantity);
                }
                else
                {
                    SpDX sp=dosp.getSp(id);
                    out.println("<font color=\"red\" size=\"4\">");
                    out.print("\""+sp.getName()+"\"");
                    out.print("的库存数量只有"+sp.getSl()+"件,请调整购买数量!<p>");
                    out.println("</font>");
                }
            }
        }
    %>
    <%
        Collection cl=gwc.getSm();
        if(cl.size()<=0)
        {
            out.println("购物车中没有商品<p>");
    %>
        <a href="index.jsp">继续购物</a>
    <%
            return;
        }
        Iterator it=cl.iterator();
    %>
        <form name="theform" action="showgwc.jsp" method="post">
            <table width="510" border=1 cellpadding=5 cellspacing=0 
                	style="border-collapse:collapse" align="left" bordercolor="#00CC99">
                <tr>
                    <th>名称</th>
                    <th>价格</th>
                    <th>数量</th>
                    <th>小计</th>
                    <th>取消</th>
                </tr>
   <%
        int i=0;
        while(it.hasNext())
        {
            Sp sp=(Sp)it.next();
            SpDX spdx=sp.getSp();
            int id=spdx.getId();
            String fieldNum="num_"+i;
            String fieldSp="sp_"+i;
    %>
                <tr>
                    <td><%=spdx.getName() %></td>
                    <td><%=spdx.getJg() %></td>
                    <td>
                        <input type="text" name="<%=fieldNum%>"
                               value="<%=sp.getSl() %>"
                               size="2"/>
                        <input type="hidden" name="<%=fieldSp%>" 
                               value="<%=id%>"/>
                    </td>
                    <td><%=sp.getSpJg() %></td>
                    <td><a href="delsp.jsp?id=<%=id%>">删除</a></td>
                </tr>
    <%
            i++;
        }
      
    %>         

                <tr>
                    <td>合计</td>
                    <td colspan="4"><%=gwc.getZjg() %></td>
                </tr>
            </table><p>
            <input type="hidden" name="itemnum" value="<%=i%>"/>
            <input type="submit" name="action" value="更新数量"/>
            &nbsp;&nbsp;&nbsp;&nbsp;
            <a href="index.jsp">继续购物</a>
            &nbsp;&nbsp;&nbsp;&nbsp;

        </form>
  </body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -