实验7 实现简单的图书在线销售系统(一)

上传人:第*** 文档编号:31136641 上传时间:2018-02-05 格式:DOC 页数:11 大小:133.50KB
返回 下载 相关 举报
实验7 实现简单的图书在线销售系统(一)_第1页
第1页 / 共11页
实验7 实现简单的图书在线销售系统(一)_第2页
第2页 / 共11页
实验7 实现简单的图书在线销售系统(一)_第3页
第3页 / 共11页
实验7 实现简单的图书在线销售系统(一)_第4页
第4页 / 共11页
实验7 实现简单的图书在线销售系统(一)_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《实验7 实现简单的图书在线销售系统(一)》由会员分享,可在线阅读,更多相关《实验7 实现简单的图书在线销售系统(一)(11页珍藏版)》请在金锄头文库上搜索。

1、淮海工学院计算机工程学院实 验 报 告 书课 程 名 J2EE 环境与程序设计题 目:实验七实现简单的图书在线销售系统 1 班 级: 软件 131 学 号: 2013122870 姓 名: 王裕 一、实验目的掌握 Spring 框架的基本使用方法,能够完成 Java 对象及对象之间的依赖注入定义,实现对象与对象间控制反转。掌握使用 Spring 将 Struts、Spring、Hibernate 三个框架在 WEB 应用中的集成。掌握图书在线销售系统主要功能模块的实现思路与方法。二、实验内容1、实现首页中的新书列表功能。2、实现将图书添加到购物车功能。3、实现购物车中图书名称、价格、数量,总价

2、的显示功能。4.注册用户,并且登陆三、实验方法和步骤准备:安装 Mysql 数据库服务器。执行 bookstore.sql.txt 中的 SQL 命令,创建项目包括的数据表。- - 数据库: bookstore- create database bookstore;use bookstore;- - - 表的结构 book- CREATE TABLE book (bookid int(11) NOT NULL auto_increment,catalogid int(11) default NULL,bookname varchar(20) NOT NULL,price int(11) NOT

3、 NULL,picture varchar(30) NOT NULL,recommend int(11) NOT NULL,PRIMARY KEY (bookid),KEY FK_Relationship_3 (catalogid) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ;- - 导出表中的数据 book- INSERT INTO book (bookid, catalogid, bookname, price, picture, recommend) VALUES (1, 1, 书 1, 11, a19.jpg, 0),(2

4、, 2, 书 2, 22, a15.jpg, 1),(3, 2, 书 3, 33, a15.jpg, 1),(5, 2, 书 5, 55, a15.jpg, 1),(6, 2, 书 6, 66, a15.jpg, 1),(7, 2, 书 7, 77, a15.jpg, 1),(8, 2, 书 8, 88, a15.jpg, 1),(9, 2, 书 9, 99, a15.jpg, 1),(10, 2, 书 10, 10, a15.jpg, 1),(11, 2, 书 11, 11, a15.jpg, 1),(12, 2, 书 12, 12, a15.jpg, 1),(13, 2, 书 13, 13

5、, a15.jpg, 1),(14, 2, 书 14, 14, a15.jpg, 1);- - - 表的结构 catalog- CREATE TABLE catalog (catalogid int(11) NOT NULL auto_increment,catalogname varchar(20) NOT NULL,PRIMARY KEY (catalogid) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;- - 导出表中的数据 catalog- INSERT INTO catalog (catalogid, catalogna

6、me) VALUES (1, 类别 1),(2, 类别 2);- - - 表的结构 orderitem- CREATE TABLE orderitem (orderitemid int(11) NOT NULL auto_increment,orderid int(11) default NULL,bookid int(11) default NULL,quantity int(11) NOT NULL,PRIMARY KEY (orderitemid),KEY FK_Relationship_2 (orderid),KEY FK_Relationship_4 (bookid) ENGINE=

7、InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;- - 导出表中的数据 orderitem- - - - 表的结构 orders- CREATE TABLE orders (orderid int(11) NOT NULL auto_increment,userid int(11) default NULL,orderdate timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,PRIMARY KEY (orderid),KEY FK_Relationshi

8、p_1 (userid) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;- - 导出表中的数据 orders- - - - 表的结构 user- CREATE TABLE user (userid int(11) NOT NULL auto_increment,username varchar(20) NOT NULL, password varchar(20) NOT NULL,sex varchar(4) default NULL,age int(11) default NULL,PRIMARY KEY (userid) ENGI

9、NE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;- - 导出表中的数据 user- INSERT INTO user (userid, username, password, sex, age) VALUES (1, admin, admin, NULL, NULL),第一步:实现数据层的对象关系映射。第二步:实现 DAO、Service 、Action 三层处理代码。第三步:通过 applictionContext.xml 完成 Bean 配置。第四步:实现视图。1、编写可保存图书信息的可持久化对象:org/apex/bookstore/vo

10、/Book.javapackage org.apex.bookstore.vo;import java.util.HashSet;import java.util.Set;/* Book entity.* * author MyEclipse Persistence Tools*/public class Book implements java.io.Serializable / Fieldsprivate Integer bookid;private Catalog catalog;private String bookname;private Integer price;private

11、String picture;/ Constructors/* default constructor */public Book() /* minimal constructor */public Book(String bookname, Integer price, String picture) this.bookname = bookname;this.price = price;this.picture = picture;/* full constructor */public Book(Catalog catalog, String bookname, Integer pric

12、e,String picture) this.catalog = catalog;this.bookname = bookname;this.price = price;this.picture = picture;/ Property accessorspublic Integer getBookid() return this.bookid;public void setBookid(Integer bookid) this.bookid = bookid;public Catalog getCatalog() return this.catalog;public void setCata

13、log(Catalog catalog) this.catalog = catalog;public String getBookname() return this.bookname;public void setBookname(String bookname) this.bookname = bookname;public Integer getPrice() return this.price;public void setPrice(Integer price) this.price = price;public String getPicture() return this.pic

14、ture;public void setPicture(String picture) this.picture = picture;2、编写 Hibernate 映射文件以实现 ORM:org/apex/bookstore/vo/Book.hbm.xml 3、在 Spring 配置文件 applicationContext.xml 中的 sessionFactory Bean 配置中合适的位置添加映射文件声明:org/apex/bookstore/vo/Book.hbm.xml4、在 org/apex/bookstore/dao/impl/BookDAO.java 中实现以下方法:public List getNewBook()Session session=getSession();Query query=session.createQuery(from Book b);query.setFirstResult(0);query.setMa

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 其它办公文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号