版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、目录第一章 概述3【实验目的】3【需求分析】3第二章 网上商店结构分析与设计3【前言】32.1 系统结构图42.2系统功能分析4第三章 详细设计53.1数据库设计53.2 商品模块实现63.2.1 模块功能实现和关键代码说明63.3 用户注册/登录模块实现103.3.1 模块功能实现和关键代码说明103.4 购物车模块实现133.4.1 模块功能实现和关键代码说明133.5 结算功能模块16第四章 总结18【技术总结】18【心得体会】18第一章 概述【实验目的】1. 掌握java-web网站设计的全过程;2. 进一步熟练Servlet技术、数据库、标签等一般java-web应用技术;3. 掌握
2、整个java-web应用架构、目录结构以及服务器使用。【需求分析】1. 设计一个较完善的网上军靴商店;2. 账户模块:提供用户注册、登录,考虑用户数量增减,需要用数据库技术;3. 商品显示模块:出于增加销售量考虑,需要有简单广告功能,并提供商品详细参数;推广商品,网站需要对热销商品展示以及商品分类显示、商品查询;4. 订单管理模块、订单详细信息模块:显示已保存的订单的详细信息;5. 购物车模块:添加/删除商品,结帐,显示订单信息。第二章 网上商店结构分析与设计【前言】随着信息化技术在生活中的应用越来越广泛,网上购物也逐渐成为人们的一种生活方式。本系统正是基于这样一种环境下应运而生。本电子商城为
3、前台部分,前台主要实现会员的网上购物业务流程、用户注册、用户资料修改。 本商城主要利用javaservlet技术进行开发,有很强的逻辑性、可扩展性,便于维护。商城界面设计主要实用了CSS,美化了店面。其次本商城设计还使用了JSP技术、JDBC技术、JavaBean技术、css。2.1 系统结构图商店前台商品查询模块用户注册模块购物车模块热销商品模块新品上市模块商品分类显示模块用户登录模块收银台模块订单显示模块图2.1 系统整体框图2.2系统功能分析新品上市模块:在首页框架中显示新品列表畅销商品模块:在首页框架中显示畅销列表购物车模块:显示已点击购买但没结账的商品结账模块:直接显示当前订单查看商
4、品信息模块:显示当前商品详细信息商品分类模块:分类显示商品全部商品模块:显示商品列表查询商品模块:搜寻商品,显示商品信息用户注册模块:实现用户注册统功能分析第三章 详细设计3.1数据库设计商品表(shoe)用户表(user)用户订单表(orderinfo)3.2 商品模块实现 3.2.1 模块功能实现和关键代码说明Begin调用mypack包下Getshoeservlet里doGet方法 返回GoodsAction查询数据库显示到主页面先由JSP页面发出请求调用mypack包下GetshoeServlet,调用里面的 doGet方法,然后调用db.executeQuery(sql)方法,查询数
5、据库,查到热销商品的列表,保存进requeset对象的resault变量里,然后通过调用取出其中的值,显示到主页面。商品查询模块按商品ID、关键词查询,商品显示模块使用同样方法根据不同条件查询数据库。主要代码如下:protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException req.setCharacterEncoding(utf-8);String typeId = req.getParameter(typeId);String shoeId
6、 = req.getParameter(shoeId);String keyword = req.getParameter(keyword);String sql = select * from shoe;String sql1 = select * from shoe where typeId = ?;String sql2 = select * from shoe where shoeId = ?;List shoelist = new ArrayList();HttpSession session = req.getSession();BookDB db = null;CachedRow
7、Set result = null;try db = new BookDB();if(typeId != null)if(typeId.equals(0)result = db.executeQuery(sql);elseresult = db.executeQuery(sql1, typeId);while(result.next()Shoe shoe = new Shoe();shoe.setType(result.getString(1);shoe.setShoeId(result.getInt(2);shoe.setName(result.getString(3);shoe.setPr
8、ice(result.getFloat(4);shoelist.add(shoe);session.setAttribute(shoelist, shoelist);resp.sendRedirect(req.getContextPath()+/catalog.jsp);if(shoeId != null)result = db.executeQuery(sql2, Integer.parseInt(shoeId);if(result.next()Shoe shoeDetail = new Shoe();shoeDetail.setType(result.getString(1);shoeDe
9、tail.setShoeId(result.getInt(2);shoeDetail.setName(result.getString(3);shoeDetail.setPrice(result.getFloat(4);shoeDetail.setSale_amount(result.getInt(5);session.setAttribute(shoedetail, shoeDetail);resp.sendRedirect(req.getContextPath()+/shoedetail.jsp);if(keyword != null)result = db.executeQuery(sq
10、l);while(result.next()if(result.getString(3).contains(keyword)Shoe shoe = new Shoe();shoe.setType(result.getString(1);shoe.setShoeId(result.getInt(2);shoe.setName(result.getString(3);shoe.setPrice(result.getFloat(4);shoelist.add(shoe);session.setAttribute(shoelist, shoelist);resp.sendRedirect(req.ge
11、tContextPath()+/catalog.jsp); catch (Exception e) / TODO Auto-generated catch blocke.printStackTrace();3.3 用户注册/登录模块实现3.3.1 模块功能实现和关键代码说明 Begin调用/ARMY-SHOES/UserLoginServlet和UserRegistServlet 返回查询/更新数据库显示regist.jsp/login.jsp先由JSP页面发出请求调用mypack包下UserRegistServlet/UserLoginServlet,调用里面的 doGet方法,然后调用db
12、.executeQuery(sql1, username, password)方法,更新数据库。主要代码如下:登录(UserLoginServlet):HttpSession session = req.getSession();try db = new BookDB();result = db.executeQuery(sql1, username, password);if (result.next() user = new User();user.setUsername(result.getString(1);user.setPassword(result.getString(2);us
13、er.setMail(result.getString(3);user.setTel(result.getString(4);session.setAttribute(user, user);resp.sendRedirect(req.getContextPath() + /index.jsp); else resp.sendRedirect(req.getContextPath() + /login.jsp?statu=no);注册(UserRegistServlet):String username = req.getParameter(username);String password
14、= req.getParameter(password);String mail = req.getParameter(mail);String tel = req.getParameter(tel);String sql1 = select * from user where username = ?;String sql2 = insert into user values(?, ?, ?, ?);BookDB db;CachedRowSet result = null;try db = new BookDB();result = db.executeQuery(sql1, usernam
15、e);if(result.next()resp.sendRedirect(req.getContextPath()+/regist.jsp?statu=no);elsedb.executeUpdata(sql2, username, password, mail, tel);resp.sendRedirect(req.getContextPath()+/regist.jsp?statu=ok);3.4 购物车模块实现 3.4.1 模块功能实现和关键代码说明Begin调用mypack包下 ShoppingCart里的add()/remove()/getTotal()方法 返回item查询数据库显
16、示showCart.jsp图3.1 购物车模块流程图先由JSP页面发出请求调用org.action包下的findId方法,findId调用DaoImpl包里的findOrderById,把得到的结果,保存到session里取名order1通过orderdetail里取变量得到这个值,显示到主页面。主要代码如下:Add()方法: public synchronized void add(String shoeId, Shoe shoe) if(items.containsKey(shoeId) ShoppingCartItem scitem = (ShoppingCartItem) items.
17、get(shoeId); scitem.incrementQuantity(); else ShoppingCartItem newItem = new ShoppingCartItem(shoe); items.put(shoeId, newItem); numberOfItems+; Remove()方法: public synchronized void remove(String shoeId) if(items.containsKey(shoeId) ShoppingCartItem scitem = (ShoppingCartItem) items.get(shoeId); sci
18、tem.decrementQuantity(); if(scitem.getQuantity() = 0) items.remove(shoeId); numberOfItems-; Gettotal()方法:public synchronized double getTotal() double amount = 0.0; for(Iterator i = getItems().iterator(); i.hasNext(); ) ShoppingCartItem item = (ShoppingCartItem) i.next(); Shoe shoe = (Shoe) item.getItem(); amount += item.getQuantity() * shoe.getPrice(); return roundOff(amount); private double roundOff(double x) long val = Math.round(x*100); / cents return val/100.0; public synchronized void clear() items.clear(); numberOfItems = 0; 3.5 结算功能模块从showcart.jsp转到cashier.jsp,调用HandleOrder
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026中国智能汽车产业竞争格局分析未来投资趋势规划研究报告
- 2026中国涡流泵市场跨界合作与生态圈建设研究报告
- 2026中国养老服务体系构建行业供需关系分析及政策支持评估发展规划研究
- 2026中国心理健康服务市场深度调研及竞争格局与投资前景研究报告
- 智能保险产品定价策略-第8篇
- 智慧投顾模型优化-第1篇
- 保险行业智能计算趋势-第1篇
- 投资组合优化策略-第1篇
- 2026中国食品添加剂行业市场供需形势分析及产业发展研究
- 2026中国新能源汽车动力电池市场供需格局现状分析投资潜力发展规划报告
- 2026年金融科技产品市场推广方案
- 指向核心素养的初中一年级英语项目式学习教案:策划与展示一场跨文化生日派对
- 2026年小学英语教师进城选调模拟考试4套试卷(含答案)
- 2026-2030中国大气等离子系统行业市场发展趋势与前景展望战略分析研究报告
- 大面积酸碱泄漏处置基本程序培训课件
- 2024年人民网总网招聘笔试参考题库含答案解析
- 第六章-古树名木的养护管理课件
- cw3-2500m万能式断路器说明书
- 渝18M01 重庆市城市道路交通安全设施安装与支撑结构设计标准图集 DJBT 50-112
- 辽宁省葫芦岛市教育心理学知识教师招聘考试
- 清华大学博士后出站报告模板
评论
0/150
提交评论