当前位置:文档之家› JSP电子商城课程设计报告

JSP电子商城课程设计报告

电子商城设计报告目录1 系统概述 (2)1.1 系统说明 (2)1.2 系统运行环境及其应用软件 (2)2 系统功能设计 (2)2.1 前台购物系统 (2)2.2 后台管理系统 (2)3 系统架构设计 (2)4 数据表结构设计 (3)5 系统运行界面 (4)错误!未定义书签。

6代码 (6)1 系统概述1.1 系统说明项目名称:网上在线购买项目简介:Easy Buy Online 在线购物系统能够实现广大用户足不出户就能在线购买自己心仪的商品。

1.2 系统运行环境及其应用软件:开发技术:Jsp+JavaBean 服务器:Tomcat6.0 数据库:mysql开发工具:Myeclipce2 系统功能设计2.1 前台购物系统:(1)可实现在线注册;(2)注册成功后,可进行登录,购买自己想要买的商品; (3)可以增、删、改商品类型;(4)还可以在线查看自己以前发送的订单以及商品信息; 2.2 后台管理系统:(1)管理员登录;(2)查看所有注册用户的信息并对其编辑,并提供高级查询; (3)查看/添加/删除商品信息,同时也提供了高级查询;(4)查看/编辑用户所发送成功的所有订单,并对其进行编辑同时也提供了高级查询;3 系统架构设计图4-1 Easy-Buy 系统三层结构数据库JSP/Java Bean前台购物后台管理HttpHttp数据 业务逻辑 用户界面4数据表结构设计表序号 1 表名Customer含义存储用户的基本信息序号属性名称含义数据类型长度说明约束1 c_name 用户名varchar 30 not null 主键2 c_pass 密码varchar 30 not null4 c_phone 电话号码varchar 11 not null5 c_address 地址 V archar 30 null表序号 3 表名Product含义存储商品信息序号属性名称含义数据类型长度说明约束1 p_type 商品类型varchar 30 not null2 p_id 商品编号varchar 10 not null 主键3 p_name 商品名称varchar 40 Not null4 p_price 商品价格float 8 not null5 p_quantity 商品数量int 4 Not null6 p_image 商品图片V archar 100 Not null7 p_description 描述信息V archar 2000 Not null表序号 6 表名OrderDetails含义商品详细表序号属性名称含义数据类型长度说明约束1 order_id 订单号char 10 not null 主键2 p_id 商品编号char 10 not null3 p_price 价格Float 8 Not null4 p_number 数量Ine 4 not null表序号8 表名Orders含义存储订单信息序号属性名称含义数据类型长度说明约束1 order_id 编号char 10 not null 主键2 order_adress 地址varchar 200 Not null3 order_user 订购者char 30 Not null4 order_time 订购时间char 30 Not null5 order_sum 总价值float 8 Not null表序号9 表名Admin含义存储管理员基本信息序号属性名称含义数据类型长度说明约束1 a_name 管理员账号V archar 30 not null2 a_pass 管理员密码varchar 30 not null3 a_phone 联系电话Char 11 Null表序号 5 表名Main_type含义添加菜单序号属性名称含义数据类型长度说明约束1 t_id 编号char 10 not null2 t_type 菜单varchar 30 not null表序号 3 表名Product含义存储商品信息序号属性名称含义数据类型长度说明约束1 p_type 产品ID varchar 30 not null2 p_id 商品编号varchar 10 not null3 p_name 产品名称varchar 40 Not null4 p_price 商品价格float 8 not null5 p_quantity 购买数量int 4 Not null5系统运行界面图一首页图二登录界面图三登录成功界面图四添加物品图五删除物品图六购物车6代码图一代码<%!privateList<Category> getTopCategories(List<Category> categories) { List<Category>topCategories=new ArrayList<Category>();for(int i=0; i<categories.size(); i++) {Category c = categories.get(i);if(c.getGrade() == 1) {topCategories.add(c);}}return topCategories;}private List<Category> getChilds(Category parent, List<Category> categories) {List<Category>childs=new ArrayList<Category>();for(int i=0; i<categories.size(); i++) {Category c = categories.get(i);if(c.getPid() == parent.getId()) {childs.add(c);}}return childs;}private String getChildsStr(List<Category> childs) {StringBuffer buf = new StringBuffer();for(int i=0; i<childs.size(); i++) {Category c = childs.get(i);buf.append("<a href='ShowProducts.jsp?categoryId=" + c.getId() + "'>").append(c.getName()).append("</a>").append("-");}return buf.toString();}%><%List<Category> categories = CategoryService.getInstance().getCategories();List<Category> topCategories = getTopCategories(categories);%><html><head><me content="zh-cn"></me><meta http-equiv="Content-Type" content="text/html; charset=gb2312"><title>电子商城- 网上精品会员店</title><link href="images/new.css" rel="stylesheet" type="text/css"><script language="javascript1.2">function js_callpage(htmlurl){Varnewwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status= no,menubar=no,scrollbars=no,resizable=yes,top=2,width=360,height=470');return false;}function js_callpage1(htmlurl){varnewwin=window.open(htmlurl,'','toolbar=no,location=no,directories=no,status= no,menubar=no,scrollbars=yes,resizable=yes,top=2,width=100,height=100');return false;}</script><script language="JavaScript">function MM_swapImgRestore() { //v3.0var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;}function MM_preloadImages() { //v3.0var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}}function MM_findObj(n, d) { //v4.01var p,i,x;if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&yers&&i<yers.length;i++)x=MM_findObj(n,yers[i].document);if(!x && d.getElementById) x=d.getElementById(n); return x;}function MM_swapImage() { //v3.0var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}function on_trview(trname,enforce){ <%for(int i=0; i<topCategories.size(); i++) {Category c = topCategories.get(i);%> document.all.pma_<%=c.getId()%>.style.display="none";<%}%>if (enforce=="in"){ eval("document.all.pma_"+trname+".style.display=''");}function MM_reloadPage(init) {//reloads the window if Nav4 resizedif (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();}MM_reloadPage(true);function MM_showHideLayers() { //v6.0var i,p,v,obj,args=MM_showHideLayers.arguments;for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; } obj.visibility=v; }}</script><script language="JavaScript">var imgUrl=new Array();var imgLink=new Array();var imgTitle=new Array();var imgPrice1=new Array();var imgPrice2=new Array();var adNum=0;imgUrl[1]='/pimages/br0465.gif';imgLink[1]='index_pi.php?productcode=BR0465';imgTitle[1]='贝尔金家用笔记本电脑便携袋(银色,膝上型)';imgPrice1[1]='价格:¥339.00';imgPrice2[1]='会员价格:¥319.00';imgUrl[2]='/pimages/br0461.gif';imgLink[2]='index_pi.php?productcode=BR0461';imgTitle[2]='贝尔金家用笔记本电便携袋(橙色,手提型)';imgPrice1[2]='价格:¥339.00';imgPrice2[2]='会员价格:¥319.00';imgUrl[3]='/pimages/gt1176.gif';imgLink[3]='index_pi.php?productcode=GT1176';imgTitle[3]='贝尔金家用笔记本便携内袋(银)';imgPrice1[3]='价格:¥369.00';imgPrice2[3]='会员价格:¥359.00';imgUrl[4]='/pimages/gt0873.gif';imgLink[4]='index_pi.php?productcode=GT0873';imgTitle[4]='3M 14.1 电脑防窥片';imgPrice1[4]='价格:¥459.00';imgPrice2[4]='会员价格:¥449.00';var imgPre=new Array();var j=0;for (i=1;i<imgUrl.length;i++) {if( (imgUrl[i]!="") && (imgLink[i]!="") ) {j++;} else {break;}}图二代码<body><form action="AdminLogin.jsp" method="post"><input type="hidden" name="action" value="login"/><table width="325" height="204" border="1" align="center"><tr><td width="105">admin name:</td><td width="162"><input type="text" size="20" name="username"/></td></tr><tr><td>admin password:</td><td><input type="password" size="20" name="password"/></td> </tr><tr><td height="66"></td><td><input type="submit" value="login" size="40"/><input type="reset" value="reset" size="40" /></td></tr></table></form></body>图三代码<%@ page language="java" import="java.util.*" pageEncoding="GBK"%> <%@ page import="er.*" %><%String username = request.getParameter("username");String password = request.getParameter("password");try {User u = User.check(username, password);session.setAttribute("user", u);} catch (UserNotFoundException e) {out.println(e.getMessage());return;} catch (PasswordNotCorrectException e) {out.println(e.getMessage());return;}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>自服务系统</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>欢迎您:lijianwei <%=username%><br><a href="UserModify.jsp">恭喜你登录成功</a><br><a href="ChangePassword.jsp">请购买物品</a></center></body></html>图四代码<%request.setCharacterEncoding("GBK");String action = request.getParameter("action");if(action != null && action.trim().equals("add")) {String name = request.getParameter("name");String descr = request.getParameter("descr");Category c = new Category();c.setPid(0);c.setName(name);c.setDescr(descr);c.setGrade(1);CategoryService service = CategoryService.getInstance();service.add(c);out.println("类别添加成功!恭喜!");return;}%><html><head><title>电子商城添加商品</title>body { scrollbar-base-color: #F3F6FA; scrollbar-arrow-color:#4D76B3; font-size: 12px; background-color: #ffffff }table { font: 12px Verdana,Tahoma; color: #000000 }input,select,textarea { font: 11px Verdana,Tahoma; color: #000000; font-weight: normal; background-color: #F3F6FA }select { font: 11px Verdana,Tahoma; color: #000000; font-weight: normal; background-color: #F3F6FA }.nav { font: 12px Verdana,Tahoma; color: #000000; font-weight: bold }.nav a { color: #000000 }.header { font: 11px Verdana,Tahoma; color: #FFFFFF; font-weight: bold; background-image: url("images/green/bg01.gif") }.header a { color: #FFFFFF }.category { font: 11px Verdana,Tahoma; color: #000000; background-color: #EFEFEF }.tableborder { background: #4D76B3; border: 0px solid #4D76B3 }.singleborder { font-size: 0px; line-height: 0px; padding: 0px; background-color: #F3F6FA }.smalltxt { font: 11px Verdana,Tahoma }.outertxt { font: 12px Verdana,Tahoma; color: #000000 }.outertxt a { color: #000000 }.bold { font-weight: bold }.altbg1 { background: #F3F6FA }.altbg2 { background: #FFFFFF }--></style><script language="JavaScript" src="images/common.js"></script><style type="text/css" id="defaultPopStyle">.cPopText { font-family: Tahoma, Verdana; background-color: #FFFFCC; border: 1px #000000 solid; font-size: 12px; padding-right: 4px; padding-left: 4px; height: 20px; padding-top: 2px; padding-bottom: 2px; visibility: hidden; filter: Alpha(Opacity=80)}</style></head><body leftmargin="0" rightmargin="0" topmargin="0" onkeydown="if(event.keyCode==27) return false;"><div id="popLayer" style="position: absolute; z-index: 1000;" class="cPopText"></div><br><table style="table-layout: fixed;" align="center" border="0" cellpadding="0" cellspacing="0" width="97%"><tbody><tr><td class="nav" align="left" nowrap="nowrap" width="90%">&nbsp;电子商城&raquo; <br></td><td align="right" width="10%">&nbsp;<a href="#bottom"><img src="images/arrow_dw.gif" align="absmiddle" border="0"></a></td></tr></tbody></table><br><form method="post" name="register" action="CategoryAdd.jsp" onSubmit="this.regsubmit.disabled=true;"><input type="hidden" name="action" value="add"/><table class="tableborder" align="center" cellpadding="4" cellspacing="1" width="97%"><tbody><tr><td colspan="2" class="header">添加类别- 必填内容</td></tr><tr><td class="altbg1" width="21%">类别名称:</td><td class="altbg2"><input name="name" size="25" maxlength="25" type="text"></tr><tr><td class="altbg1" valign="top">类别描述:</td><td class="altbg2"><textarea name="descr" cols="60" rows="5" id="descr"></textarea></td></tr></tbody></table><br><center><input name="regsubmit" value="提&nbsp; 交" type="submit"></center></form></body></html>图五代码<%int id = Integer.parseInt(request.getParameter("id"));String url = request.getParameter("from");User.delete(id);%><html><head><title>删除用户</title></head><body><center>恭喜您, 删除成功!<br><span id="delay" style="background:red">3</span>秒钟后跳转到上一页面, 或者请点击下面的链接自己跳转<br><a href="<%=url%>"><%=url%></a></center><script type="text/javascript">parent.main.location.reload();</script></body></html>图六代码<%Cart c = (Cart)session.getAttribute("cart");if(c == null) {c = new Cart();session.setAttribute("cart", c);}%><%request.setCharacterEncoding("GBK");String action = request.getParameter("action");if(action != null && action.trim().equals("add")) {int id = Integer.parseInt(request.getParameter("id"));Product p = ProductMgr.getInstance().loadById(id);CartItem ci = new CartItem();ci.setProduct(p);ci.setCount(1);c.add(ci);}if(action != null && action.trim().equals("delete")) {int id = Integer.parseInt(request.getParameter("id"));c.deleteItemById(id);}if(action != null && action.trim().equals("update")) {for(int i=0; i<c.getItems().size(); i++) {CartItem ci = c.getItems().get(i);int count = Integer.parseInt(request.getParameter("p" + ci.getProduct().getId()));ci.setCount(count);}}%><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort ()+path+"/";%><%List<CartItem> items = c.getItems();%><html><head><meta http-equiv="Content-Type" content="text/html; charset=GB18030"><title>购物车</title></head><body><form action="Buy.jsp" method="get"><input type="hidden" name="action" value="update"/><table align="center" border="1"><tr><td>产品ID</td><td>产品名称</td><td>购买数量</td><td>单价</td><td>总价</td></tr><%for(Iterator<CartItem> it = items.iterator(); it.hasNext(); ) {CartItem ci = it.next();%><tr><td><%=ci.getProduct().getId() %></td><td><%=ci.getProduct().getName() %></td><td><input type="text" size=3 name="<%="p" + ci.getProduct().getId() %>" value="<%=ci.getCount() %>"></td><td><%=ci.getProduct().getNormalPrice() %></td><td><%=ci.getProduct().getNormalPrice()*ci.getCount() %></td><td><a href="Buy.jsp?action=delete&id=<%=ci.getProduct().getId() %>">删除</a></td></tr><%}%><tr><td colspan=6><a href="Confirm.jsp">下单</a><a href="javascript:document.forms[0].submit()">修改</a</td></tr></table></form></body></html>。

相关主题