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

📄 __eshop.java

📁 网上购物系统 使用structs access 实现
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            try{ //[ /eshop.jsp; Line: 14]                String[] arrayProduct = request.getParameterValues("cpbm"); //[ /eshop.jsp; Line: 15]                String strCheck = ""; //[ /eshop.jsp; Line: 16]                //[ /eshop.jsp; Line: 17]                System.out.println("选购商品的产品编码长度为:" + arrayProduct.length); //[ /eshop.jsp; Line: 18]                //[ /eshop.jsp; Line: 19]                if (arrayProduct.length == 0){ //[ /eshop.jsp; Line: 20]                    strCheck = "no"; //[ /eshop.jsp; Line: 21]                } //[ /eshop.jsp; Line: 22]                String productList = (String)request.getSession(true).getAttribute("productList"); //[ /eshop.jsp; Line: 23]                //[ /eshop.jsp; Line: 24]                System.out.println("选购商品的产品编码列表为:" + productList); //[ /eshop.jsp; Line: 25]                //System.out.println("********" + (productList == null)); //[ /eshop.jsp; Line: 26]                //[ /eshop.jsp; Line: 27]                for (int i=0; i<arrayProduct.length; i++){ //[ /eshop.jsp; Line: 28]                    System.out.println("选购商品的产品编码列表变化为:" + productList); //[ /eshop.jsp; Line: 29]                    this.puttoShopBag(arrayProduct[i],productList); //[ /eshop.jsp; Line: 30]                } //[ /eshop.jsp; Line: 31]                request.getSession(true).setAttribute("productList", productList); //[ /eshop.jsp; Line: 32]                //[ /eshop.jsp; Line: 33]                String head = "以下是您所选购的物品清单"; //[ /eshop.jsp; Line: 34]                productList = (String)request.getSession(true).getAttribute("productList"); //[ /eshop.jsp; Line: 35]                if (productList.length() == 0){ //[ /eshop.jsp; Line: 36]                    response.sendRedirect("nothing.jsp"); //[ /eshop.jsp; Line: 37]                    return; //[ /eshop.jsp; Line: 38]                } //[ /eshop.jsp; Line: 39]                String strMySelf = request.getParameter("MySelf"); //[ /eshop.jsp; Line: 40]                if (strMySelf.equals("Yes")){ //[ /eshop.jsp; Line: 41]                    productList = ""; //[ /eshop.jsp; Line: 42]                    String[] arrayCpbm = request.getParameterValues("cpbm"); //[ /eshop.jsp; Line: 43]                    for (int i=0;i<arrayCpbm.length;i++){ //[ /eshop.jsp; Line: 44]                        this.puttoShopBag(arrayCpbm[i],productList); //[ /eshop.jsp; Line: 45]                    } //[ /eshop.jsp; Line: 46]                    request.getSession(true).setAttribute("productList", productList); //[ /eshop.jsp; Line: 47]                } //[ /eshop.jsp; Line: 48]                if (productList.length() == 0){ //[ /eshop.jsp; Line: 49]                    response.sendRedirect("nothing.jsp"); //[ /eshop.jsp; Line: 50]                    return; //[ /eshop.jsp; Line: 51]                } //[ /eshop.jsp; Line: 52]                //数据库连接 //[ /eshop.jsp; Line: 53]                Class.forName("oracle.jdbc.driver.OracleDriver"); //[ /eshop.jsp; Line: 54]                String strUrl = "jdbc:oracle:thin:@slight:1521:LOCAL"; //[ /eshop.jsp; Line: 55]                String strUser = "eshop"; //[ /eshop.jsp; Line: 56]                String strPassword = "eshop"; //[ /eshop.jsp; Line: 57]                Connection con = DriverManager.getConnection(strUrl, strUser, strPassword); //[ /eshop.jsp; Line: 58]                Statement st = con.createStatement(); //[ /eshop.jsp; Line: 59]                String sql = "select * from product where product_id in (" + productList +")"; //[ /eshop.jsp; Line: 60]                ResultSet rs = st.executeQuery(sql); //[ /eshop.jsp; Line: 61]                out.print("\r\n<html>\r\n<head>\r\n<title>\r\n以下是您所选购的物品清单\r\n</title>\r\n<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\r\n</head>\r\n<script language=\"Javascript\">\r\n//函数名:fucCheckNUM\r\n//功能介绍:检查是否为数字\r\n//参数说明:要检查的数字\r\n//返回值:1为是数字,0为不是数字\r\nfunction fucCheckNUM(NUM)\r\n{\r\n\tvar i,j,strTemp;\r\n\tstrTemp=\"0123456789\";\r\n\tif ( NUM.length== 0)\r\n\t\treturn 0\r\n\tfor (i=0;i<NUM.length;i++)\r\n\t{\r\n\t\tj=strTemp.indexOf(NUM.charAt(i));\r\n\t\tif (j==-1)\r\n\t\t{\r\n\t\t//说明有字符不是数字\r\n\t\t\treturn 0;\r\n\t\t}\r\n\t}\r\n\t//说明是数字\r\n\treturn 1;\r\n}\r\n\r\nfunction clean()\r\n {\r\n  window.location.href=\"clear.asp\"\r\n  }\r\n</script>\r\n<SCRIPT language=javascript id=clientEventHandlersJS>\r\n<!--\r\nfunction form1_onsubmit()\r\n{\r\nnewprice=\"Q_\" & rs(\"Product_Id\")\r\n \tif ((fucCheckNUM(document.FORM1.newprice.value)==0) )\r\n\t{\talert (\"会员价有非法字符,请填写正确会员价。\");\r\n\t\tdocument.FORM1.newprice.focus();\r\n\t\treturn false;\r\n\t}\r\n//-->\r\n}\r\n</SCRIPT>\r\n<body topmargin=\"5\">\r\n\r\n<div align=\"center\">\r\n\r\n<table width=\"80%\" border=\"0\" cellspacing=\"0\">\r\n  <tr>\r\n    <td width=\"80%\" valign=\"top\">\r\n      <p align=\"center\">\r\n<font col");                out.print("or=\"#FF0000\" >");                out.print(String.valueOf(head));  //[ /eshop.jsp; Line: 120]                out.print("</font></p>\r\n      <!--webbot BOT=\"GeneratedScript\" PREVIEW=\" \" startspan --><script Language=\"JavaScript\"><!--\r\nfunction FrontPage_Form1_Validator(theForm)\r\n{\r\n\r\n  var checkOK = \"0123456789-\";\r\n  var checkStr = theForm.");                    out.print(String.valueOf("Q_" + rs.getString("Product_Id")));  //[ /eshop.jsp; Line: 126]                    out.print(".value;\r\n  var allValid = true;\r\n  var decPoints = 0;\r\n  var allNum = \"\";\r\n  for (i = 0;  i < checkStr.length;  i++)\r\n  {\r\n    ch = checkStr.charAt(i);\r\n    for (j = 0;  j < checkOK.length;  j++)\r\n      if (ch == checkOK.charAt(j))\r\n        break;\r\n    if (j == checkOK.length)\r\n    {\r\n      allValid = false;\r\n      break;\r\n    }\r\n    allNum += ch;\r\n  }\r\n  if (!allValid)\r\n  {\r\n    alert(\"在 请输入正确的商品数量! 域中,只能输入 数字 个字符。\");\r\n    theForm.");                        out.print(String.valueOf("Q_" + rs.getString("Product_Id")));  //[ /eshop.jsp; Line: 146]                        out.print(".focus();\r\n    return (false);\r\n  }\r\n  return (true);\r\n}\r\n//-->\r\n</script>\r\n\r\n<form Action=\"eshop.jsp\" Method=\"POST\" onsubmit=\"return FrontPage_Form1_Validator(this)\" name=\"FrontPage_Form1\">\r\n<input type=\"hidden\" name=\"MySelf\" value=\"Yes\">\r\n<table border=\"0\" cellspacing=\"1\" width=\"550\" class=main bgcolor=\"#000000\">\r\n        <tr bgcolor=\"#006699\">\r\n          <td align=\"center\" width=\"82\"  height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品编号</font></td>\r\n          <td align=\"center\" width=\"170\"  height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品名称</font></td>\r\n          <td align=\"center\" width=\"76\" height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品价格</font></td>\r\n          <td align=\"center\" width=\"76\"  height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">商品数量</font></td>\r\n          <td align=\"center\" width=\"60\"  height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">购买</font></td>\r\n          <td align=\"center\" width=\"72\"  height=\"22\" bgcolor=\"#006699\"><font color=\"#EEEEEE\">总价</font></td>\r\n        </tr");                out.print(">\r\n");                //[ /eshop.jsp; Line: 165]                double dbSum = 0; //[ /eshop.jsp; Line: 166]                DecimalFormat df = new DecimalFormat("0.00"); //[ /eshop.jsp; Line: 167]                while(rs.next()){ //[ /eshop.jsp; Line: 168]                    int Quatity = Integer.parseInt(request.getParameter("Q_" + rs.getString("product_id"))); //[ /eshop.jsp; Line: 169]                    if (Quatity <=0){ //[ /eshop.jsp; Line: 170]                        Quatity = 1; //[ /eshop.jsp; Line: 171]                    } //[ /eshop.jsp; Line: 172]                    request.getSession(true).setAttribute("product_id", String.valueOf(Quatity)); //[ /eshop.jsp; Line: 173]                    dbSum = dbSum + rs.getDouble("p_newprice") * Quatity; //[ /eshop.jsp; Line: 174]                    out.print("\r\n        <tr>\r\n          <td align=\"center\" width=\"82\" bgcolor=\"#EEEEEE\">");                    out.print(String.valueOf(rs.getString("Product_ID")));  //[ /eshop.jsp; Line: 177]                    out.print("</td>\r\n          <td align=\"center\" width=\"170\" bgcolor=\"#EEEEEE\">");                    out.print(String.valueOf(rs.getString("Product_Name")));  //[ /eshop.jsp; Line: 178]                    out.print("</td>\r\n          <td align=\"center\" width=\"76\" bgcolor=\"#EEEEEE\">");                    out.print(String.valueOf(df.format(rs.getDouble("P_NewPrice"))));  //[ /eshop.jsp; Line: 179]                    out.print("</td>\r\n          <td align=\"center\" width=\"76\" bgcolor=\"#EEEEEE\"><input Name=\"");                    out.print(String.valueOf("Q_" + rs.getString("Product_Id")));  //[ /eshop.jsp; Line: 180]                    out.print("\" Value=\"");                    out.print(String.valueOf(Quatity));  //[ /eshop.jsp; Line: 180]                    out.print("\" Size=\"3\"></td>\r\n          <td Align=\"center\" width=\"60\" bgcolor=\"#EEEEEE\"><input Type=\"CheckBox\" Name=\"cpbm\" Value=\"");                    out.print(String.valueOf(rs.getString("Product_Id")));  //[ /eshop.jsp; Line: 181]                    out.print("\" Checked></td>\r\n          <td Align=\"center\" width=\"72\" bgcolor=\"#EEEEEE\">");                    out.print(String.valueOf(df.format(rs.getDouble("P_NewPrice")*Quatity)));  //[ /eshop.jsp; Line: 182]                    out.print("元</td>\r\n      </tr>\r\n");                    //[ /eshop.jsp; Line: 184]                } //[ /eshop.jsp; Line: 185]                out.print("\r\n      <tr>\r\n        <td Align=\"Right\" ColSpan=\"6\" width=\"546\" bgcolor=\"#EEEEEE\">\r\n          <font Color=\"Red\">总价格=人民币 ");                out.print(String.valueOf(df.format(dbSum)));  //[ /eshop.jsp; Line: 189]                out.print(".00元</font>\r\n        </td>\r\n      </tr>\r\n    </table>\r\n      <blockquote>\r\n        <input Type=\"submit\" Value=\"更改数量\" name=\"B1\" style=\"font-size: 9pt\">&nbsp;&nbsp;&nbsp;\r\n        <input type=\"button\" value=\"继续购物\" name=\"B2\" onclick=\"window.close();\" style=\"font-size: 9pt\">&nbsp;&nbsp;&nbsp;\r\n        <input type=\"button\" value=\"订单取消\" name=\"B3\" OnClick=\"clean()\" style=\"font-size: 9pt\">&nbsp;&nbsp;&nbsp;\r\n        <input type=\"button\" value=\"去收银台\" onClick=\"window.open(\'ment.asp\',window.close(), \'Sample\', \'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,copyhistory=yes,width=610,height=600,left=100,top=100\')\" name=\"b4\">      <p align=\"center\"><font color=\"#FF0000\">注意:改变“商品数量需按“更改数量”</font>\r\n      </blockquote>\r\n   </form>\r\n    </td>\r\n</tr>\r\n</table>\r\n\r\n</div>\r\n</body>\r\n</html>\r\n");                //[ /eshop.jsp; Line: 207]            }catch(Exception e){ //[ /eshop.jsp; Line: 208]                //错误处理 //[ /eshop.jsp; Line: 209]                throw (e); //[ /eshop.jsp; Line: 210]            } //[ /eshop.jsp; Line: 211]        } catch (Throwable __ee) {            while (out != null && out != _originalOut) out = pageContext.popBody();            ((weblogic.servlet.jsp.PageContextImpl)pageContext).handlePageException((Throwable)__ee);        }                
        //before final close brace...
    }
    
    
}

⌨️ 快捷键说明

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