zoukankan      html  css  js  c++  java
  • 编写一个简易购物车,实现向购物车内添加商品,移除指定商品及清空购物车功能。

    showp.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    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 'shocar..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>
    <form id="form1" name="form1" method="post" action="login.jsp">
    银行卡号:
    <input name="username" type="text" id="username"/><br>
    密&nbsp;&nbsp;码:
    <input name="pd" type="password" id="pwd"/><br>
    <input type="submit" name="Submit" value="提交"/>
    </form>
    </body>
    </html>

    index.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    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 'index.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>
    <center><b>购物车已清空!</b></center><br>
    <center><a href="show.jsp"> 返回</a></center><!-- 超链接 -->


    </body>
    </html>

    docar.jsp:

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    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 'docar.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>
    <%
    String action=request.getParameter("action");
    if(action==null)
    action="";
    if(action.equals("buy"))
    {
    response.sendRedirect("shopcar.jsp");
    }
    else if(action.equals("remove"))
    {
    response.sendRedirect("remove.jsp");
    }
    else if(action.equals("clear"))
    {
    %> 
         <%response.sendRedirect("index.jsp");
    }

    %>
    </body>
    </html>

    shocar.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    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 'docar.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>
    <%
    String action=request.getParameter("action");
    if(action==null)
    action="";
    if(action.equals("buy"))
    {
    response.sendRedirect("shopcar.jsp");
    }
    else if(action.equals("remove"))
    {
    response.sendRedirect("remove.jsp");
    }
    else if(action.equals("clear"))
    {
    %> 
         <%response.sendRedirect("index.jsp");
    }

    %>
    </body>
    </html>

    login.jsp:

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    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 'login.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>
    已购买。<br>
    <a href="show.jsp">继续购物</a>
    </body>
    </html>

    remove.jsp

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
    <%
    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 'remove.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>
    该功能没有实现,请不要乱点. <br>
    </body>
    </html>

  • 相关阅读:
    iOS -Swift 3.0 -for(循环语句用法)
    C++ 中的std::vector介绍(转)
    C++ 中的sort排序用法
    iOS获取当前AppStore版本号与更新
    cocos2dx 3.x(获得父类的node型指针调用父类函数this->getParent())
    cocos2dx 3.x(TexturePacker进行图片加密)
    cocos2dx 3.x(屏幕截图的两种方法)
    cocos2dx 3.x(在Mac平台下利用Eclipse打包安卓apk安装包详细教程)
    cocos2dx 3.x(定时器或延时动作自动调用button的点击响应事件)实现自动内测
    cocos2dx 3.x(移动修改精灵坐标MoveTo与MoveBy)
  • 原文地址:https://www.cnblogs.com/cancangood/p/4451976.html
Copyright © 2011-2022 走看看