资料清单

  1. 项目源码(eclipse版 + idea版)
  2. 数据库sql文件
  3. 线上蛋糕商城项目论文
  4. 线上蛋糕商城项目答辩PPT

该项目虽然是蛋糕商城项目,但是可以复用成其他商城项目或者购物车项目。想要相关资料的uu可绿泡泡:SUMYY17

项目技术栈

servlet+jsp+bootstrap+css+mysql

功能模块

用户

  1. 用户注册
  2. 用户登录
  3. 商品分类
  4. 浏览蛋糕
  5. 选购蛋糕
  6. 购物车模块
  7. 购物车结算

管理员
8. 管理员登录
9. 用户列表管理
10. 管理员列表管理
11. 商品管理

效果图展示

登录

在这里插入图片描述

首页展示

在这里插入图片描述
在这里插入图片描述

选购商品

在这里插入图片描述

购物车结算

在这里插入图片描述

后台管理系统

在这里插入图片描述

设计图

在这里插入图片描述

部分源码

  • index.jsp
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();  
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	pageContext.setAttribute("basePath", basePath);
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
	<base href="${basePath}">
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>BON CAKE</title>
	<link rel="stylesheet" href="bs/css/bootstrap.css">
	<script type="text/javascript" src="bs/js/jquery.min.js"></script>
	<script type="text/javascript" src="bs/js/bootstrap.js"></script> 
	<link href="css/cake/head_footer.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="js/cake/getCatalog.js"></script> 
	<script type="text/javascript" src="js/cake/index.js"></script> 
	<script type="text/javascript" src="js/cake/landing.js"></script>
	<link rel="stylesheet" href="css/cake/index.css" />
	<script type="text/javascript" src="js/cake/addcart.js"></script>
	
	<style type="text/css">
		.dropdown-menu{
			margin:0;
		}
	</style>

</head>
<body>

	<div class="container-fullid">
		<%@include file="header.jsp" %>
		<div class="wrapper">
			<!-- banner start -->
			<div class="banner" style="margin-top:-19px;">
				<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
					<!-- Indicators -->
					<ol class="carousel-indicators">
						<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
						<li data-target="#carousel-example-generic" data-slide-to="1"></li>
						<li data-target="#carousel-example-generic" data-slide-to="2"></li>
					</ol>
					<!-- Wrapper for slides -->
					<div class="carousel-inner" role="listbox">
						<div class="item active">
							<img src="images/cake/banner1.jpg" alt="...">
						</div>
						<div class="item">
							<img src="images/cake/banner2.jpg" alt="...">
						</div>
						<div class="item">
							<img src="images/cake/banner3.jpg" alt="...">
						</div>
						
					</div>
				
				    <!-- Controls -->
					<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
					    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
					</a>
					<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
					    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
					</a>
				</div>
			</div>
			<!-- main start -->
			<div class="main container">
				<div class="row">
					<div class="col-md-2 main-left">
						<h3>商品分类</h3>
						
						<ul id="catalog-list">
							<li><a href="CakeList">所有商品</a></li>
							
						</ul>
					</div>
					
					<div class="search col-md-4 col-md-offset-6" style="margin-top:20px;">
						<div class="input-group">
							<form action="CakeList2" method="get">
		     	 				<input style="float: left;width: 160px;" type="text" class="form-control" name="seachname" placeholder="输入要搜索商品">
		       					&nbsp;&nbsp;&nbsp;
		       					<span style="float: left;width: 40px;" class="btn btn-default" type="submit" ><img class="icon" src="images/cake/search-icon.png" alt=""></span>
							</form>
   						</div>
					</div> 
					<div class="col-md-10 main-right" style="margin-top:-52px;">
						<div class="pro col-md-12">
							<h3>推荐商品</h3>
							<div id="recCakes" class="pro-list">
								<ul> 
								
									
								</ul>
							</div>
								
						</div>
						<div class="pro col-md-12">
							<h3>新品上市</h3>
							<div id="newCakes" class="pro-list">
								<ul > 
									
								</ul>
							</div>
						</div>
					</div>
					
				</div>
			</div>
		</div>
		<br/><br/>
		
		<%@include file="footer.jsp" %>
	</div>
	<!--弹窗盒子start -->
	<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
	  	<div class="modal-dialog modal-sm">
	    	<div class="modal-content" style="margin-top:300px;">
	    		<div class="modal-body" style="color:green;font-size:20px;">
	    		  	<img class="icon" src="images/cake/success-icon.png" alt="">
				  	 已成功加入购物车
				</div>
	    			
	      		<div class="modal-footer">
	      			<a href="javascript:void(0)" type="button" class="btn btn-md btn-default" data-dismiss="modal">返回继续购物</a>
			        <a href="jsp/cake/cart.jsp" type="button" class="btn btn-md btn-success">立即去结算</a>
			    </div>
	    	</div>
	  	</div>
	</div>
	<!--弹窗盒子end -->
</body>
</html>
  • cart.jsp
<%@page import="java.util.List"%>
<%@page import="java.util.ArrayList"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	pageContext.setAttribute("basePath", basePath);
%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>购物车</title>
<link rel="stylesheet" href="bs/css/bootstrap.css">
<script type="text/javascript" src="bs/js/jquery.min.js"></script>
<script type="text/javascript" src="bs/js/bootstrap.js"></script>
<script type="text/javascript" src="js/cake/landing.js"></script>
<link href="css/cake/head_footer.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/cake/addcart.js"></script>
<link rel="stylesheet" type="text/css" href="bs/validform/style.css">
<script type="text/javascript" src="bs/validform/Validform_v5.3.2_min.js"></script> 
<script type="text/javascript" src="js/cake/user_reg_login.js"></script>
<style type="text/css">
.wrapper {
	minheight: 400px;
}

.wrapper .main {
	padding: 20px 50px;
}

.wrapper .main .content .spinner a {
	display: inline-block;
}

.wrapper .main .content .spinner input {
	display: inline-block;
	width: 30px;
	height: 22px;
	border-radius: 3px;
}

</style>

</head>
<body>
	<c:if test="${!empty suberr}">
		<script type="text/javascript">
			alert("${suberr}")
		</script>
	</c:if>
	<div class="container-fullid">
		<%@include file="header.jsp" %>
		<div class="wrapper">
			<!-- main start -->
			<div class="main container">
				<h3>
					<span>我的购物车</span>
				</h3>
				<div class="content table-responsive">
					<table class="table">
						
						<c:choose>
							<c:when test="${!empty shopCart}">
								<tr class="info row">
									<th class="col-md-6" style="background:#fff;" >商品</th>
									<th class="col-md-2" style="background:#fff;" >单价</th>
									<th class="col-md-2" style="background:#fff;" >数量</th>
									<th class="col-md-2" style="background:#fff;" >小计</th>
									<th class="col-md-1" style="background:#fff;" >操作</th>
								</tr>
								<c:forEach items="${shopCart.map}" var="i">
									<tr class="row" id="pro-tr-${i.key}">
										<td><img class="img-responsive col-md-4"
											src="${i.value.cake.upLoadImg.imgSrc }" alt="" />
											<div class="col-md-8" style="padding:50px 0 50px 0;">
												<a href="cakedetail?cakeId=${i.key}">${i.value.cake.cakeName}</a>
												<%-- <p>${i.value.cake.author}</p>
												<p>${i.value.cake.press}</p> --%>
											</div>
										</td>
										<td style="padding:50px 0 50px 0;"><i>${i.value.cake.price}</i></td>
										<td style="padding:50px 0 50px 0;">
											<div class="spinner">
												<span onclick="addval(this,${i.key})"
													class="btn btn-xs btn-default"> <b>-</b>
												</span> 
												<input type="text" value="${i.value.quantity}" onchange="changeinput(this,${i.key})" >
												<span onclick="cutval(this,${i.key})"
													class="btn btn-xs btn-default"> <b>+</b>
												</span>
											</div>
										</td>
										<td class="price" style="color:#D3B145;font-size:20px;padding:50px 0 50px 0;"><i>${i.value.subtotal}</i></td>
										<td><a href="CartServlet?action=delItem&id=${i.key}" onClick="return confirm('确定要删除此项了么?')">
										<img class="icon" src="images/cake/close-icon.png" alt="" style="margin:50px 0 50px 0;width:15px"></a></td>
									</tr>
								</c:forEach>
								<tr class="row">
									<td colspan="2"><a href="CartServlet?action=delAll" class="btn btn-md" style="background:#D3B145;color:#fff;">清空购物车</a></td>
									<td class="pull-right" style="font-size: 24px;">合计:</td>
									<td id="totPrice"><b style="color:#D3B145;font-size: 24px;"><i>
										<c:choose>
											<c:when test="${!empty shopCart}">
												${shopCart.totPrice}
											</c:when>
											<c:otherwise>
												0.00
											</c:otherwise>
										</c:choose>
										
										</i></b></td>
									<td><a id="tosettle" class="btn btn-md" style="background:#333333;color:#fff;" href="javascript:void(0)">去结算</a></td>
								</tr>
							</c:when>
							<c:otherwise>
								<tr>
									<td colspan="6"
										style="height: 200px; line-height: 100px; font-size: 24px;">
										购物车内暂时没有商品, <a style="font-size: 24px; color: red"
										href="CakeList">去购物>></a>
									</td>
								</tr>
							</c:otherwise>
						</c:choose>
						
					</table>

				</div>
			</div>
		</div>

		<%@include file="footer.jsp" %>
	</div>

	<!-- 弹窗 -->
	<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
					<h4 class="modal-title" id="myModalLabel">登录</h4>
				</div>
				<div class="modal-body">
					<!-- //登录表单主体 -->
					<p class="info" style="text-align: center;color:red"></p>
	        		<div id="tab_login" class="tab-pane fade in active">
						<form id="loginForm" name="loginForm"  method="post" class="form-horizontal" >
							<div class="form-group">
								<label for="l_userName" class="col-md-4 control-label">用户名:</label>
								<div class="col-md-6">
									<input name="userName" id="l_userName" type="text" class="form-control" >
									<span class="Validform_checktip">&nbsp;</span>
								</div>
								
							</div> 
							<div class="form-group">
								<label for="l_passWord" class="col-md-4  control-label">密码:</label>
								<div class="col-md-6">
									<input type="password" name="passWord" id="l_passWord" class="form-control">
									<span class="Validform_checktip">&nbsp;</span>
								</div>
								
							</div>
							
							<div class="form-group">
								<label for="ck_code" class="col-md-4  control-label">验证码:</label>
								<div class="col-md-3" >
									<input class="form-control" type="text" name="code" id="ck_code" >
									<span class="Validform_checktip">&nbsp;</span>
								</div>
								
								<div class="col-md-4" style="padding:0;">
									<img class="col-md-8" id="imgCode" src="CodeServlet?action=code" alt="" style="padding:0;width:100px;height:38px;" />
									<span onclick="reCode()" class="col-md-4 glyphicon glyphicon-refresh " aria-hidden="true" style="padding:0 0 0 5px;font-size: 24px;"></span>
								</div>
								
							</div>
							<div class="form-group">
								<label class="col-md-2 control-label col-md-offset-4">
									<button class="btn btn-success btn-md" type="submit" >登录</button>
								</label>
								<label class="col-md-2 control-label">
									<button class="btn btn-warning btn-md" type="reset">重置</button>
								</label>
								
							</div>
						</form>
					</div>
				</div>
				
			</div>
		</div>
	</div>
	<script type="text/javascript">
	//登录验证
	
		
		var form=$("#loginForm").Validform({
			tiptype:3
		});
		
		form.addRule([
			{
				ele:"#l_userName",
			    datatype:"*",
			    nullmsg:"*请输入用户名!",
			    errormsg:"*用户名输入不正确,请重新输入!" 
			},
			{ 
				ele:"#l_passWord",
				datatype:"*",
				nullmsg:"*请输入密码!",
				errormsg:"*密码输入不正确,请重新输入"
			},
			{ 
				ele:"#ck_code",
				datatype:"*",
				ajaxurl:"CodeServlet?action=ckCode",
				nullmsg:"*请输入验证码!",
				errormsg:"*验证码输入不正确"
			}
		
		]);
		
	
	//增减按钮处理
	  function addval(obj,id) {  
		  var input=$(obj).parent().find("input");
		  if(input.val()>1){
			  input.val(parseInt(input.val()) - 1); 
			  changeQ(obj,id,input.val());
			}
		 }
	  function cutval(obj,id){
		  var input=$(obj).parent().find("input");
		  if(input.val()<999){
			  input.val(parseInt(input.val()) + 1); 
			  changeQ(obj,id,input.val());
			}
	 	}
	  //输入框处理
		function changeinput(obj,id){
			var val=$(obj).val();
			var rge=/^[0-9]*[1-9][0-9]*/;
			if(!rge.test(val)){
				$(obj).val(1);
				changeinput(obj,id);
				alert("商品数量为整数,请重新输入!");
				return;
			}else{
				changeQ(obj,id,val);
			}
			
		}
		function ckinput(val){
			
		}
		//ajax提交处理
		function changeQ(obj,id,val){
			$.ajax({
				url:"CartServlet?action=changeIn",
				dataType:"json",
				async:true,
				data:{"cakeId":id,"quantity":val},
				type:"POST",
				success:function(data){
					$(obj).parent().parent().parent().find(".price i").html(data.subtotal);
					$(obj).parent().find("input").val(data.quantity);
					$("#totPrice i").html(data.totPrice);
					$("#cart .num").html(data.totQuan);
					
				}
					
			})
		}
		//去结算处理
		$("#tosettle").click(function(){
			$.get("UserServlet?action=landstatus",function(data){
				if(data.status=="y"){
					window.location.href="${basePath}jsp/cake/conorder.jsp";
				}else{
					$("#myModal").modal("show");
				}
			},"json")
			
			return;
		})
		//登陆处理
		$("#loginForm").submit(function(){
			$.post("UserServlet?action=ajlogin", $('#loginForm').serialize(),function(data){
				if("y"==data.status){
					window.location.href="${basePath}jsp/cake/conorder.jsp";
					
				}else{
					
					$("#myModal .info").html(data.info);
				}
			},"json")
			return false;
		})
		
		
		
		//验证码 
	function reCode(){
		$("#imgCode").prop("src","CodeServlet?action=code&"+new Date().getTime());
	}
</script>
</body>
</html>
  • cake类
package bean;

import java.util.Date;
import java.util.Map;

public class Cake {

	private int cakeId; // 商品编号
	private String cakeName; //  商品名称
	private double price; // 价格
	private String description; // 描述信息
	private int catalogId; //商品分类id
	private int imgId; // 图片id
	private Date addTime;//上架时间

	private Catalog catalog = new Catalog(); //
	private UpLoadImg upLoadImg = new UpLoadImg(); //

	public Cake() {
	}

	// �����Ǵ����ݿ��ȡʱ����ת����
	public Cake(Map<String, Object> map) {
		this.cakeId = (int) map.get("cakeId");
		this.cakeName = (String) map.get("cakeName");
		this.price = (double) map.get("price");
		this.description = (String) map.get("description");
		this.addTime=(Date) map.get("addTime");
		this.catalog = new Catalog(map);
		this.upLoadImg = new UpLoadImg(map);
	}

	public int getCakeId() {
		return cakeId;
	}

	public void setCakeId(int cakeId) {
		this.cakeId = cakeId;
	}

	public String getCakeName() {
		return cakeName;
	}

	public void setCakeName(String cakeName) {
		this.cakeName = cakeName;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public int getCatalogId() {
		return catalogId;
	}

	public void setCatalogId(int catalogId) {
		this.catalogId = catalogId;
	}

	public int getImgId() {
		return imgId;
	}

	public void setImgId(int imgId) {
		this.imgId = imgId;
	}

	public Date getAddTime() {
		return addTime;
	}

	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}

	public Catalog getCatalog() {
		return catalog;
	}

	public void setCatalog(Catalog catalog) {
		this.catalog = catalog;
	}

	public UpLoadImg getUpLoadImg() {
		return upLoadImg;
	}

	public void setUpLoadImg(UpLoadImg upLoadImg) {
		this.upLoadImg = upLoadImg;
	}

	@Override
	public String toString() {
		return "Cake [cakeId=" + cakeId + ", cakeName=" + cakeName + ", price=" + price + ", description=" + description
				+ ", catalogId=" + catalogId + ", imgId=" + imgId + ", addTime=" + addTime + ", catalog=" + catalog
				+ ", upLoadImg=" + upLoadImg + "]";
	}
}

资料清单

  1. 项目源码(eclipse版 + idea版)
  2. 数据库sql文件
  3. 线上蛋糕商城项目论文
  4. 线上蛋糕商城项目答辩PPT

需要资料请关注点赞后私聊哈!

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐