大型实验-JSP 网上书店
专业:软件工程 065 班
项目组成员:
2008 年 12 月 20 日
1. 系统分析.........................................................................................................................................5
1.1. 需求分析..............................................................................................................................5
1.2. 可行性分析..........................................................................................................................6
2. 总体设计.........................................................................................................................................6
2.1. 项目规划..............................................................................................................................6
2.2. 系统功能结构图..................................................................................................................6
2.3. 网站主要业务流程..............................................................................................................7
3. 系统设计.........................................................................................................................................8
3.1. 设计目标..............................................................................................................................8
3.2. 开发及运行环境..................................................................................................................9
3.3. 总体设计..............................................................................................................................9
网上书城的架构由三层组成:表示层、功能层和数据层,如下图所示。........................9
.....................................................................................................................................................9
图 4 网上书城总体结构.............................................................................................................9
数据访问引擎:提供对不同数据库管理系统(Oracle、SQL Server)、不同数据库访问
引擎(各种 JDBC、各种 ODBC、各种 JDBC/ODBC 桥)的封装,实现对异构、分布数
据的透明访问。.......................................................................................................................10
- 1 -
姓名 学号 电话
方明星
200626630508 13656685298
冯炳彭
200626630509
赵晨
200626630528
毛耀宽
200626630515
祁鸿斐
200626630516
3.4. 本系统采用的体系结构为 B/S 体系结构........................................................................10
3.5. 使用 AJAX 技术................................................................................................................10
这种旧的途径让我们认识到了许多技术,但它不会产生很好的用户体验。当服务器正
在处理自己的事情的时候,用户在做什么?没错,等待。每一个动作,用户都要等待。
很明显,如果我们按桌面程序的思维设计 Web 应用,我们不愿意让用户总是等待。当
界面加载后,为什么还要让用户每次再花一半的时间从服务取数据?实际上,为什么
老是让用户看到程序去服务器取数据呢?...........................................................................11
3.6. 采用 MVC 框架.................................................................................................................11
M(model): order.java bean 类.........................................................................................13
V ( view ) :
customerview.jsp、shopping_n.jsp、failedBuy.jsp、successBuy.jsp、customerview_y.jsp、
shopping_y.jsp、gb_success.jsp、gb_failure.jsp、bought.jsp、_bought.jsp、sucBuy.jsp...13
C ( control ) :
changeAmount.java、Delete.java、Buy.java、hasRecieved.java、order_process.java、give
Back.java...................................................................................................................................13
留言板:...................................................................................................................................13
用 struts 框架实现 MVC,配置文件为 struts-config.xml....................................................13
M(model): lyForm.java...................................................................................................13
C(control): lyAction.java、ly.java.................................................................................13
3.7. 模块化设计........................................................................................................................13
4. 数据库设计...................................................................................................................................14
4.1. 商品大分类信息表............................................................................................................14
4.2 商品信息表.................................................................................................................14
商品信息表主要用来保存每个商品的基本信息。表 book 的结构如表所示:........14
4.3 订单信息表.................................................................................................................14
4.4 用户信息表.................................................................................................................15
4.5 留言信息表.................................................................................................................15
5. JavaBean 的编写...........................................................................................................................15
a) 数据库操作的 ConnectDB 的编写......................................................................................15
b) 保存订单信息的 order.java 的编写.....................................................................................16
package bean.book;...................................................................................................................16
public class order {....................................................................................................................16
private int orderId; //订单号....................................................................................................16
private int bookId; //书号.........................................................................................................16
private int bookNumber; //书数量...........................................................................................16
private String userName;//用户名...........................................................................................16
private String orderState;//发货状态.......................................................................................16
private String bookState;//购买状态.......................................................................................17
private String bookName;//书名..............................................................................................17
private String bookAuthor;//书作者........................................................................................17
...................................................................................................................................................17
public order() {//成员变量初始化..........................................................................................17
orderId=0;.................................................................................................................................17
bookId=0;.................................................................................................................................17
- 2 -
bookNumber=0;.......................................................................................................................17
userName="";...........................................................................................................................17
orderState="";...........................................................................................................................17
bookState="";...........................................................................................................................17
bookName="";..........................................................................................................................17
bookAuthor="";........................................................................................................................17
}................................................................................................................................................17
...................................................................................................................................................17
public int getOrderId(){//获取订单号.....................................................................................17
return orderId;..........................................................................................................................17
}................................................................................................................................................17
public int getBookId(){//获取书号..........................................................................................17
return bookId;...........................................................................................................................17
}................................................................................................................................................17
public int getBookNumber(){//获取书数量............................................................................17
return bookNumber;.................................................................................................................17
}................................................................................................................................................17
public String getUserName(){//获取用户名...........................................................................17
return userName;......................................................................................................................17
}................................................................................................................................................17
public String getOrderState(){//获取发货状态.......................................................................17
return orderState;......................................................................................................................17
}................................................................................................................................................17
public String getBookState(){//获取购买状态.......................................................................17
return bookState;......................................................................................................................17
}................................................................................................................................................17
public String getBookName(){//获取书名..............................................................................17
return bookName;.....................................................................................................................17
}................................................................................................................................................17
public String getBookAuthor(){//获取书作者........................................................................17
return bookAuthor;...................................................................................................................17
}................................................................................................................................................17
...................................................................................................................................................17
public void setOrderId(String orderId){//设置订单号............................................................17
this.orderId=Integer.parseInt(orderId.trim());..........................................................................17
}................................................................................................................................................17
public void setBookId(String bookId){//设置书号.................................................................17
this.bookId=Integer.parseInt(bookId.trim());...........................................................................18
}................................................................................................................................................18
public void setBookNumber(String bookNumber){//设置书数量.........................................18
this.bookNumber=Integer.parseInt(bookNumber.trim());.......................................................18
}................................................................................................................................................18
public void setUserName(String userName){//设置用户名...................................................18
this.userName=userName.trim();.............................................................................................18
- 3 -
}................................................................................................................................................18
public void setOrderState(String orderState){//设置发货状态..............................................18
this.orderState=orderState.trim();............................................................................................18
}................................................................................................................................................18
public void setBookState(String bookState){//设置购买状态...............................................18
this.bookState=bookState.trim();.............................................................................................18
}................................................................................................................................................18
public void setBookName(String bookName){//设置书名....................................................18
this.bookName=bookName.trim();..........................................................................................18
}................................................................................................................................................18
public void setBookAuthor(String bookAuthor){//设置书作者.............................................18
this.bookAuthor=bookAuthor.trim();.......................................................................................18
}................................................................................................................................................18
}.................................................................................................................................................18
c) 保存商品信息的 Books.java 的编写...................................................................................18
d) 对商品信息操作的编写......................................................................................................19
(1) 买书的操作,Buy.java 中首先获取到用户点击的书名,然后通过该书的 ID 将书的
信息从数据库中搜索出来,然后转到购物车的页面。......................................................19
try{............................................................................................................................................19
name=request.getParameter("username").trim();//获取书的名字..........................................19
}catch(Exception e){ }.............................................................................................................19
try{............................................................................................................................................19
ConnectDB conn=new ConnectDB();//连接数据库,找出对应的书的信息。..................19
conn.sqlStr="Update userOrder set OrderState=1 where UserName='"+name+"'";...............19
conn.stmt.executeUpdate(conn.sqlStr);//执行查找操作.........................................................19
}catch(Exception e){}..............................................................................................................19
address="./successBuy.jsp";.....................................................................................................19
response.sendRedirect(address);..............................................................................................19
e) 对商品进行搜索操作...........................................................................................................19
if(searchtype.equals("BookAuthor")){//按作者名进行搜索..................................................19
connDB.sqlStr = "select * from book where BookAuthor like '%"+keyword+"%'";.............19
}................................................................................................................................................19
else............................................................................................................................................19
if(searchtype.equals("BookPub")){//按出版社进行搜索.......................................................19
connDB.sqlStr = "select * from book where BookPub like '%"+keyword+"%'";..................19
}................................................................................................................................................19
else............................................................................................................................................19
if(searchtype.equals("BookName")){//按书名进行搜索........................................................19
connDB.sqlStr = "select * from book where BookName like '%"+keyword+"%'";...............19
}................................................................................................................................................19
try{............................................................................................................................................19
connDB.rs = connDB.stmt.executeQuery(connDB.sqlStr);....................................................19
while(connDB.rs.next()) //搜索相关的书籍以及该书的全部信息.......................................20
{................................................................................................................................................20
- 4 -
books b = new books();............................................................................................................20
b.setBookName(connDB.rs.getString("BookName"));...........................................................20
b.setBookId(connDB.rs.getString("BookId"));.......................................................................20
b.setBookAuthor(connDB.rs.getString("BookAuthor"));.......................................................20
b.setBookPub(connDB.rs.getString("BookPub"));..................................................................20
b.setBookInfo(connDB.rs.getString("BookInfo"));.................................................................20
b.setBookPrice(connDB.rs.getFloat("BookPrice"));...............................................................20
b.setBookAmout(connDB.rs.getInt("BookAmout"));.............................................................20
b.setBookClass(connDB.rs.getString("BookClass"));.............................................................20
b.setBookType(connDB.rs.getString("BookType"));..............................................................20
list.add(b); //把相关书籍添加进一个数组中存放.................................................................20
}................................................................................................................................................20
6. 前台运行.......................................................................................................................................20
a) 前台首页...............................................................................................................................20
b) 会员登录和注册..................................................................................................................21
c) 会员资料修改.......................................................................................................................22
d) 搜索商品...............................................................................................................................23
e) 购买商品...............................................................................................................................23
如果要删除购物车中的商品,只需单击【X】按钮,商品即被删除,如果继续购物,
...................................................................................................................................................24
单击【继续购买】按钮,即返回首页,继续购物。..........................................................24
f) 支付宝...................................................................................................................................24
g) 留言板...................................................................................................................................24
7. 后台运行.......................................................................................................................................25
a) 管理员登陆...........................................................................................................................25
b) 后台管理...............................................................................................................................25
c) 商品管理...............................................................................................................................26
d) 订单管理...............................................................................................................................27
...................................................................................................................................................27
图 25..........................................................................................................................................27
e) 会员管理...............................................................................................................................27
8. 人员分工.......................................................................................................................................28
1. 系统分析
1.1. 需求分析
通过对一些典型电子商务网站的考察、分析以及实际的市场调查,要求本系统具有以
下功能:
统一友好的操作界面,能保证系统的易用性。
- 5 -