ImageVerifierCode 换一换
格式:DOCX , 页数:23 ,大小:705.62KB ,
资源ID:3728466      下载积分:12 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3728466.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(综合性实验报告模版.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

综合性实验报告模版.docx

1、综合性实验报告模版 软件学院综合性实验报告专业:JAVA 年级/班级: 09计算机1班 20102011学年第二学期课程名称Java EE程序设计指导教师周运姓名李金振学号0928524068实验地点过街楼机房实验时间5月20、27、6月3、10、17日上午1-2节项目名称用SSH框架开发网上书店实验类型综合性一、 实验目的1.熟悉并掌握spring框架。2.熟悉struts框架,了解struts2的工作机制及工作流程。3.掌握hibernate语言的使用,能够实现对数据库的增删查改。4.熟悉开发流程,能够开发网上书店。二、 实验仪器或设备1. 计算机一台2. 开发软件MyEclipse,和数

2、据库软件MySQL。三、 总体设计(设计原理、设计方案及流程等)1. 创建网上书店的数据库。2. 创建web工程。3. 加载Spring框架,以及所需的jar包,在Spring中创建相应的java类,构造bean对象,并调用bean对象。4. 进行数据库的链接。5. 加载hibernate框架,对数据进行持久化。6. 对数据库中对应的表进行hibernate逆向工程,以生成与之对应的java类。7. 加载struts框架及所需要的jar包。8. 对网上书店进行部署应用程序,启动测试。四、 实验步骤(包括主要步骤、代码分析等)1. 在MySQL中创建bookstore.sql(代码如下:)Cre

3、ate database bookstore;Use bookstore;create table book( bookid int auto_increment not null, catalogid int, bookname varchar(20) not null, price int not null, picture varchar(30) not null, primary key (bookid);create table catalog(catalogid int auto_increment not null, catalogname varchar(20) not nul

4、l, primary key (catalogid);create table orderitem( orderitemid int auto_increment not null, orderid int, bookid int, quantity int not null, primary key (orderitemid);create table orders( orderid int auto_increment not null, userid int, orderdate timestamp not null, primary key (orderid);create table

5、 user( userid int auto_increment not null, username varchar(20) not null, password varchar(20) not null, sex varchar(4), age int, primary key (userid);alter table book add constraint FK_Relationship_3 foreign key (catalogid) references catalog (catalogid) on delete restrict on update restrict;alter

6、table orderitem add constraint FK_Relationship_2 foreign key (orderid) references orders (orderid) on delete restrict on update restrict;alter table orderitem add constraint FK_Relationship_4 foreign key (bookid) references book (bookid) on delete restrict on update restrict;alter table orders add c

7、onstraint FK_Relationship_1 foreign key (userid) references user (userid) on delete restrict on update restrict;2. 在MyEclipse中创建webProject,命名为bookstore。3. 加载Spring框架,添加用户自定义包hibernate和配置文件applicationContext.xml.4. 在MyEclipse Database Explorer中创建数据库的链接。5. 加载hibernate框架。点击next6. 在MyEclipse Database Ex

8、plorer中选中所创建的表,进行hibernate逆向工程,生成与数据库表对应的java对象和映射文件。7. 修改web.xml,代码如下: web-app version=2.5 xmlns= xmlns:xsi=http:/www.w3.org/2001/XMLSchema-instance xsi:schemaLocation= index.jsp struts2 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter struts2 /* org.springframework.web.context

9、.ContextLoaderListener contextConfigLocation /WEB-INF/applicationContext.xml 8. 加载struts框架,并加载所需要的jar包。9. 创建DAO,BaseDAO.java,IBookDAO.java,ICatalogDAO.java,IUserDAO.javaBaseDAO.java代码如下:package org.apex.bookstore.dao;import org.hibernate.SessionFactory;import org.hibernate.classic.Session;public cla

10、ss BaseDAO private SessionFactory sessionFactory; public SessionFactory getSessionFactory() return sessionFactory; public void setSessionFactory(SessionFactory sessionFactory) this.sessionFactory=sessionFactory; public Session getSession() Session session=sessionFactory.openSession(); return session

11、; IBookDAO.java代码如下:package org.apex.bookstore.dao;import java.util.List;import org.apex.bookstore.vo.Book;public interface IBookDAO public List getBookByCatalogid(Integer catalogid); public List getBookByCatalogidPaging(Integer catalogid,int currentPage,int pageSize); public int getTotalByCatalog(I

12、nteger catalogid); public Book getBookById(Integer bookid); public List getRequiredBookByHql(String hql); public List getNewBook();ICatalogDAO.java代码如下:package org.apex.bookstore.dao;import java.util.List;public interface ICatalogDAO public List getAllCatalogs();IUserDAO.java代码如下:package org.apex.bo

13、okstore.dao;import org.apex.bookstore.vo.User;public interface IUserDAO public void saveUser(User user); public User validateUser(String username,String password); public boolean exitUser(String username);10. 创建service,IBookService.java, ICatalogService.java, IUserService.javaIBookService.java代码如下:p

14、ackage org.apex.bookstore.service;import java.util.List;import org.apex.bookstore.vo.Book;public interface IBookService public List getBookByCatalogid(Integer catalogid); public List getBookByCatalogidPaging(Integer catalogid,int currentPage,int pageSize); public int getTotalByCatalog(Integer catalo

15、gid); public Book getBookById(Integer bookid); public List getRequiredBookByHql(String hql); public List getNewBook();ICatalogService.java代码如下:package org.apex.bookstore.service;import java.util.List;public interface ICatalogService public List getAllCatalogs(); IUserService.java代码如下: package org.ap

16、ex.bookstore.service;import org.apex.bookstore.vo.User;public interface IUserService public void saveUser(User user); public User validateUser(String username,String password); public boolean exitUser(String username);11. 创建action,包括BookAction.java和UserAction.javaBookAction.java代码如下:package org.apex

17、.bookstore.action;import java.util.List;import java.util.Map;import org.apex.bookstore.service.IBookService;import org.apex.bookstore.service.ICatalogService;import org.apex.bookstore.util.Pager;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;public class Bo

18、okAction extends ActionSupport protected ICatalogService catalogService; protected IBookService bookService; protected Integer catalogid; private Integer currentPage=1; private String bookname; private int minPrice; private int maxPrice; public Integer getCatalogid() return catalogid; public void se

19、tCatalogid(Integer catalogid) this.catalogid = catalogid; public ICatalogService getCatalogService() return catalogService; public void setCatalogService(ICatalogService catalogService) this.catalogService = catalogService; public String browseCatalog() throws Exception List catalogs=catalogService.

20、getAllCatalogs(); Map request=(Map)ActionContext.getContext().get(request); request.put(catalogs,catalogs); return SUCCESS; public String browseBookPaging() throws Exception int totalSize=bookService.getTotalByCatalog(catalogid); Pager pager=new Pager(currentPage,totalSize); /List books=bookService.

21、getBookByCatalogid(catalogid); List books=bookService.getBookByCatalogidPaging(catalogid, currentPage, pager.getPageSize(); Map request=(Map)ActionContext.getContext().get(request); request.put(books, books); request.put(pager,pager); /购物车要返回时,需要记住返回的地址 Map session=ActionContext.getContext().getSess

22、ion(); request.put(catalogid,catalogid); return SUCCESS; public String browseBook() throws Exception List books=bookService.getBookByCatalogid(catalogid); Map request=(Map)ActionContext.getContext().get(request); request.put(books,books); return SUCCESS; public String searchBook() throws Exception S

23、tringBuffer hql = new StringBuffer(from Book b ); if(bookname!=null&bookname.length()!=0) hql.append(where b.bookname like % + bookname +%); / if(minPrice !=0 & maxPrice !=0)/ hql.append( and b.price +minPrice + and b.price +maxPrice); List books = bookService.getRequiredBookByHql(hql.toString(); Ma

24、p request = (Map)ActionContext.getContext().get(request); System.out.println(hql); System.out.println(bookname); request.put(books,books); return SUCCESS; public String newBook() throws Exception List books=bookService.getNewBook(); Map request=(Map)ActionContext.getContext().get(request); request.p

25、ut(books, books); return SUCCESS; public IBookService getBookService() return bookService; public void setBookService(IBookService bookService) this.bookService = bookService; public Integer getCurrentPage() return currentPage; public void setCurrentPage(Integer currentPage) this.currentPage = curre

26、ntPage; public String getBookname() return bookname; public void setBookname(String bookname) this.bookname = bookname; UserAction.java代码如下: package org.apex.bookstore.action;import java.util.Map;import org.apex.bookstore.service.IUserService;import org.apex.bookstore.service.impl.UserService;import

27、 org.apex.bookstore.vo.User;import com.opensymphony.xwork2.ActionContext;import com.opensymphony.xwork2.ActionSupport;public class UserAction extends ActionSupport protected String username; protected String password; protected String sex; protected int age; protected User user; protected IUserServi

28、ce userService; public User getUser() return this.user; public void setUser(User user) this.user=user; public void setUserService(IUserService userService) this.userService=userService; public IUserService getUserService() return this.userService; public String execute() throws Exception User u=userService.validateUser(user.getUsername(),user.getPassword(); if(u !=null) Map sessio

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1