【JavaWeb】JSP使用Session、Cookie实现购物车

购物界面shop.jsp

初始页面
在这里插入图片描述
添加商品后,在session中设置属性,重定向回到shop.jsp,然后根据session的内容显示结果
Cookie设置setMaxAge可以延长session的寿命
清空购物车就是清除session
在这里插入图片描述

<%@ page import="javax.jms.Session" %>
<%@ page import="java.util.*" %>
<%@ page import="java.net.URLDecoder" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/8/12
  Time: 10:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>购物</title>
    <style>
        #big{
    
    
            margin-left: 200px;
        }
        .pro img,.pro2 img{
    
    
            width: 200px;
            height: 200px;
            display: block;
            margin: 20px;
        }
        a{
    
    
            border: 2px solid black;
            border-radius: 5px;
            font-weight: bold;
            font-size: 16px;
            color: black;
        }
        a:link{
    
    
            text-decoration: none;
        }
        a:visited{
    
    
            color: black;
        }
        a:hover{
    
    
            color: green;
        }
        a:active{
    
    
            text-decoration: underline;
        }
        .pro a{
    
    
            margin-left: 20px;
            background-color: pink;
        }
        .pro2 a{
    
    
            margin-right: 20px;
            background-color: greenyellow;
        }
        .pro,.pro2{
    
    
            float: left;
            text-align: center;
        }
        .rec{
    
    
            position: relative;
            top: 20px;
            padding: 20px;
            width: 80%;
            height: 400px;
            border
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值