JavaWEB(MVC购物车02)

这篇博客详细介绍了在JavaWeb中使用MVC模式实现购物车功能的过程,包括商品显示和加入购物车的步骤。首先,展示了如何通过Servlet获取数据库中的商品数据进行显示。接着,重点讲解了加入购物车的流程,从获取商品编号到调用加入购物车的后台方法,再到成功后跳转至购物车界面。最后,提供了加入购物车Servlet和购物车显示页面的代码片段。
摘要由CSDN通过智能技术生成

目录

  1.  商品显示

  2. 加入购物车

商品显示

代码:

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <!-- 引入 -->
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>主界面</title>

<style type="text/css">
	#likes{
		width: 200px;
		 background: red; 
		height: 200px;
		text-align: right;
		display: inline;
		/* border:1 slid red ; */
	}

</style>

<link type="text/css" rel="stylesheet" href="css/style.css" />
</head>
<body>
<div id="header" class="wrap">
	<div id="logo">卓京信息网上书城</div>
	<div id="navbar">
		<div class="userMenu">
			<ul>
				<li class="current"><a href="index.jsp">User首页</a></li>
				<li><a href="queryorders.do">我的订单</a></li>
				<li><a href="Cart.do">购物车</a></li>
				<li><a href="#">注销</a></li>
			</ul>
		</div>
		<form method="get" name="search" action="indexServlet.do">
			搜索:<input class="input-text" type="text" name="strName" /><input class="input-btn" type="submit" name="submit" value="" />
			
		</form>
	</div>
	<!-- 搜索提示 div -->
		<div id="likes" ></div>
</div>
<div id="content" class="wrap">
	<div class="list bookList">
		<form method="post" name="shoping" action="Cart.do">
			<table>
				<tr class="title">
					<th class="checker"></th>
					<th>书名</th>
					<th class="price">价格</th>
					<th class="store">库存</th>
					<th class="view">图片预览</th>
					<th>操作</th>
				</tr>
				<c:if test="${empty GoodsList }">
					<jsp:forward page="indexServlet.do"></jsp:forward>
				</c:if>
				
				<c:forEach items="${GoodsList }" var="goods">
				<tr id="${goods.gid }">
					<td><input type="checkbox" name="bookId" value="${goods.gid }" /></td>
					<td class="title">${g
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值