javaWeb图书管理系统
- 格式:doc
- 大小:308.50 KB
- 文档页数:25
图书管理系统java课程设计报告一、教学目标本课程旨在通过学习Java语言实现图书管理系统,使学生掌握Java编程的基本语法和面向对象编程思想,具备运用Java语言解决实际问题的能力。
具体目标如下:1.知识目标:–掌握Java基本语法和数据结构;–理解面向对象编程的基本概念和方法;–熟悉图书管理系统的业务流程和设计方法。
2.技能目标:–能够使用Java编写简单的程序;–能够运用面向对象编程思想进行程序设计;–能够独立完成图书管理系统的开发和调试。
3.情感态度价值观目标:–培养学生的团队合作意识和沟通能力;–培养学生的问题解决能力和创新精神;–培养学生的自主学习能力和持续进步意识。
二、教学内容本课程的教学内容主要包括Java基本语法、数据结构、面向对象编程思想和图书管理系统的设计与实现。
具体安排如下:1.Java基本语法:介绍Java语言的基本元素、运算符、控制结构等;2.数据结构:讲解数组、链表、栈和队列等基本数据结构的使用和实现;3.面向对象编程:讲解类和对象、继承和多态、封装等基本概念和应用;4.图书管理系统:介绍图书管理系统的业务需求、设计方法和实现技巧。
三、教学方法本课程采用讲授法、案例分析法和实验法等多种教学方法,以激发学生的学习兴趣和主动性。
1.讲授法:通过讲解基本概念、原理和方法,使学生掌握相关知识;2.案例分析法:通过分析实际案例,使学生理解图书管理系统的业务流程和设计方法;3.实验法:通过动手实践,使学生熟悉Java编程环境和开发工具,提高编程能力。
四、教学资源本课程的教学资源包括教材、参考书、多媒体资料和实验设备等。
1.教材:选用权威、实用的Java编程教材,如《Java核心技术》等;2.参考书:提供相关的Java编程参考书籍,如《Java编程思想》等;3.多媒体资料:制作课件、视频等多媒体教学资料,以便学生随时复习和巩固知识;4.实验设备:提供计算机、网络等实验设备,确保学生能够进行实验和实践。
基于Java Web的图书管理系统的设计与实现随着信息技术的迅猛发展,图书管理系统在图书馆、图书商店等场所的应用越来越广泛。
基于Java Web的图书管理系统具有跨平台、易于维护和扩展等优势,已成为目前图书管理系统开发的主要技术选择。
本文将详细介绍基于Java Web的图书管理系统的设计与实现。
一、系统需求分析在进行图书管理系统的设计与实现之前,首先需要进行系统需求分析。
根据实际应用场景,我们将图书管理系统的主要功能模块分为以下几个方面:1. 图书管理:包括图书的录入、查询、修改和删除等功能。
管理员可以通过系统录入图书信息,并对图书信息进行增删改查操作,同时可以根据图书的分类、作者、出版社等条件进行高级查询。
2. 借阅管理:包括借书和还书的功能。
用户可以通过系统进行图书借阅,并在图书归还时办理还书手续。
在借阅过程中,系统需要实现图书的可借数量管理、借阅记录的生成以及逾期处理等功能。
3. 用户管理:包括用户的注册、登录和个人信息管理等功能。
用户可以通过系统注册账号,并使用账号进行登录和个人信息的管理,如修改密码、查看借阅记录等。
4. 权限管理:包括管理员和普通用户两种角色的权限管理。
管理员具有对系统的所有功能模块进行管理的权限,而普通用户只能进行图书查询和借阅等操作。
二、系统设计与实现经过系统需求分析,接下来将开始进行系统设计与实现。
1. 技术选型基于Java Web的图书管理系统,我们选择使用以下技术进行设计与实现:- 后端开发框架:Spring MVC- 前端UI框架:Bootstrap- 数据库:MySQL- 数据库访问框架:MyBatis- 前端页面交互:JavaScript、jQuery2. 数据库设计在实现图书管理系统之前,我们需要设计数据库表来存储图书信息、用户信息、借阅记录等数据。
下面是数据库表的设计:- 图书表(book):包含图书的编号、名称、作者、出版社、分类等字段。
- 用户表(user):包含用户的编号、账号、密码等字段。
基于JavaWeb的图书馆座位预约系统设计与实现作者:林琴王庆伟来源:《电脑知识与技术》2019年第05期摘要:随着网络技术的逐步发展,图书馆也将会改变它的服务模式,而采用以现代计算机技术和网络技术为主的服务模式,图书馆座位预约系统具有一定的实用价值。
该文通过充分调研传统的图书馆座位管理的不足和功能需求,采用JavaWeb和 MySQL数据库技术设计并实现了图书馆座位预约系统,可以解决传统占座模式存在的问题,提高图书馆座位的利用率。
关键词:图书馆;座位预约系统;JavaWeb;MySQL中图分类号:TP393 文献标识码:A 文章编号:1009-3044(2019)05-0078-02Design and Implementation of Library Seat Reservation System Based on JavaWebLIN Qin1, WANG Qing-wei2(1. School of Computer, Hefei Normal University, Hefei 230601, China; 2. Anhui Weitai Intelligent Technology Co. Ltd, Hefei 230088,China)Abstract: With the gradual development of network technology, the library will change its service mode, and the use of modern computer technology and network technology based service mode, the library seat reservation system has a certain practical value. By fully investigating the deficiencies and functional requirements of traditional library seat management, this paper designs and implements the library seat reservation system by using JavaWeb and MySQL database technology, which can solve the problems existing in the traditional seat reservation mode and improve the utilization rate of library seats.Key words:library; seat reservation system; JavaWeb; MySQL1 概述近些年,普遍出现各大高校日益增长的学生与有限的图书馆座位资源相矛盾的现象,所以图书馆座位变成了比较紧缺的资源,尤其每年考研开始和学校期末考试的时候,更是很难在图书馆找到空闲的座位。
目录摘要 (1)1. 设计背景 (2)2. 作品设计目的及意义 (3)3. 作品简介 (4)4. 功能介绍 (5)5. 数据库设计 (6)6. 总体方案设计 (10)7. 总结与致谢 (31)8. 参考文献 (33)1.设计背景随着信息技术的发展,计算机已被广泛的应用于社会的各个领域,成为推动社会发展的技术动力。
而在计算机应用中,软件的作用十分突出,软件已经发展成为信息技术的核心,主导着信息产品的开发和信息技术市场的进一步的开拓。
软件产业已成为社会信息化进程中的一个战略性产业。
在软件技术的应用中软件的开发技术尤其是应用型软件产品的开发技术成了重中之重。
不断开发适应用户需求、市场需要的新型软件产品。
尤其是在校园里,各种软件的应用无处不在,为我们的学习和生活提供了方便。
学校的图书馆不仅给我们提供看书学习的地方,还给我们提供了一套功能齐全的图书馆系统,方便我们搜索书籍、借阅图书。
我们本次的Java课程设计的最终目标是实现一个图书馆管理系统,使其具有一般图书管理系统所具有的功能,可以实现管理员日志、管理员添加、管理员退出、读者添加、读者修改、读者查询、读者删除、新书入库、书籍查询、书籍借阅与归还等功能。
因为Java是一门很优秀的编程语言,具有面向对象、与平台无关、安全、稳定和多线程等特点,所以用Java 编程为我们本次程序的编写提供了方便。
在设计中我们主要进行了数据库及类的设计,把整系统分成了15个类和5个表。
通过应用awt、swing、sql、util等包,合理的添加了按钮、菜单、文本框、文本区、表格等组件类,还包含窗口、面板等容器类,经过设计者合理的布局,完成了窗体的设计,并通过建立JDBC-ODBC桥接器连接到Access数据库后,向数据库发送SQL语句实现程序与数据库中表间的消息通信,从而实现了相应的图书馆管理系统的功能。
系统功能介绍中详细介绍了本图书管理系统的整体思想及其具体功能。
在数据库需求分析中详细说明了数据库的需求分析、概念设计及表的设计。
专业:xxx 班级: xx 编号:xxxx学院基于WEB技术的图书管理系统的设计与实现学院:信息技术分院专业:信息管理姓名:xx班级:高职软件班指导教师: xx2015年4月18日摘要随着网络技术的发展、计算机应用水平的提高的扩大,原来系统的时效性、数据的正确性、操作的方便性上都存在不足,已影响到系统的正常使用。
经过考察比较,决定利用自己的力量对图书管理系统重新设计,使系统能利用软件开发技术的成果,方便图书的管理。
图书管理系统是典型的信息管理系统。
系统介绍了图书系统的开发过程,设计中遇到的问题及解决方法以及提高当前应用程序或系统开发进度和改善工作性能. 利用其提供的各种面向对象的开发工具,首先在短时间内建立系统应用原型,然后,对初始原型系统进行需求迭代,不断修正和改进,直到形成用户满意的可行系统。
本次课程设计利用JA V A开发工具和SQL SERVER 2005数据库来开发这个图书管理系统。
该系统要解决的图书管理所要解决的问题,可以满足图书管理基本要求,包括添加、管理等功能。
该系统能根据用户的需求,快捷方便的为读者提供借阅服务。
关键词:图书管理管理信息系统数据库 JAVA目录摘要 (I)第1章课题背景与意义 (1)1.1 课题背景 (1)1.2 图书管理系统简介 (1)1.3 计算机信息系统的发展 (2)1.4 图书管理系统的发展现状 (2)1.5 开发图书管理系统应注意的问题错误!未定义书签。
1.6 可行性分析 (3)1.7 系统开发步骤 (4)第2章开发环境 (6)2.1 Java开发环境 (6)2.2 SQL SERVER 2005简介 (7)2.2.1 SQL Server 特点 (7)2.2.2 SQL Server 2005新特性 (7)第3章系统分析 (8)3.1 处理对象 (8)3.2 业务分析 (8)3.3 图书管理系统数据流程图 (8)3.4 系统功能模块图 (11)3.5 数据库的设计 (11)3.4.1 概念结构设计 (11)3.4.2 逻辑结构设计 (12)第4章数据库实施 (14)4.1 根据以上分析,建立数据库、数据表: (21)4.2 创建各个功能的触发器 (23)第5章系统流程设计 (14)5.1系统操作流程图 (14)5.2 数据增加流程 (15)5.3 数据修改流程 (16)5.4数据删除流程 (16)第6章系统设计 (18)6.1 用户登陆 (18)6.2 添加图书信息 (19)6.3 图书类别管理 (19)6.4 图书借阅管理 (20)6.5 用户信息管理 (20)结束语 (26)致谢 (28)参考文献 (29)第1章绪论1.1 研究背景随着计算机技术的飞速发展,计算机在企业管理中应用的普及,利用计算机实现图书信息的管理势在必行。
图书馆管理系统(JavaWeb)图书馆管理系统(Java Web)概述基于Spring + Spring MVC + MyBatis的图书馆管理系统,使⽤Maven进⾏包管理。
主要功能包括:图书查询、图书管理、图书编辑、读者管理、图书的借阅与归还以及借还⽇志记录等。
项⽬演⽰<——点击跳转<——点击跳转<——点击跳转<——点击跳转环境配置需要提前配置好Maven环境,数据库为MySql,在src/main/resources/db.properties中修改MySql⽤户名和密码。
数据库脚本在library.sql中,可⾃动建库。
使⽤mvn jetty:run可快速搭建。
特别注意:如果要搭⼊服务器中使⽤,⽤tomcat跑需要将项⽬打包⼊tomcat中的root⽂件夹使⽤,因为项⽬设计时,⽤的jetty,所有jsp⽂件路径写的都是相对路径。
概念设计⽤户分为两类:读者、图书馆管理员。
图书馆管理员可以修改读者信息,修改书⽬信息,查看所有借还⽇志等;读者仅可以修改个⼈信息、借阅或归还书籍和查看⾃⼰的借还⽇志。
数据库E-R图逻辑设计共有6个表:1. 图书书⽬表book_info名类型长度⼩数点NULL⽤途键book_id bigint200否图书号✔name varchar200否书名author varchar150否作者publish varchar200否出版社ISBN varchar150否标准书号introduction text00是简介language varchar40否语⾔price decimal102否价格pub_date date00否出版时间class_id int110是分类号number int110是剩余数量2. 数据库管理员表admin名类型长度⼩数点NULL⽤途键admin_id bigint200否账号✔password varchar150否密码username varchar150是⽤户名3. 图书分类表class_info名类型长度⼩数点NULL⽤途键class_id int110否类别号✔class_name varchar150否类别名4. 借阅信息表lend_list名类型长度⼩数点NULL⽤途键ser_num bigint200否流⽔号✔book_id bigint200否图书号reader_id bigint200否读者证号lend_date date00是借出⽇期back_date date00是归还⽇期5. 借阅卡信息表reader_card名类型长度⼩数点NULL⽤途键reader_id bigint200否读者证号✔password varchar150否密码username varchar150是⽤户名6. 读者信息表reader_info名类型长度⼩数点NULL⽤途键reader_id bigint200否读者证号✔name varchar100否姓名sex varchar20否性别birth date00否⽣⽇address varchar500否地址phone varchar150否电话功能展⽰1. ⾸页登陆管理者账号:123456/123456(见数据库admin表)读者账号:10000/123456()见数据库reader_card表2. 管理员系统⽤登陆进⼊2.1 图书管理2.2 图书详情2.3 读者管理2.4 借还管理3. 读者系统3.1 查看全部图书3.2 个⼈信息查看,可以修个个⼈信息3.3 个⼈借阅情况查看。
淮南联合大学计算机系
课
程
实
训
报
告
书
实训科目: 图书管理系统
专业班级:11级计算机应用技术
学号: 20118031139
姓名: 吕昌盛
实训时间: 2012-12-18
一、课程实训目的
《JAVA Web开发》课程实训是计算机应用技术专业集中实践性环节之一,是学习完《JAVA语言程序设计》课程后,继续学习《Java Web开发》进行的一次全面的综合练习,其目的是为学生提供了一个既动手又动脑,独立实践的机会,将课本上的理论知识和实际应用问题进行有机结合,锻炼学生分析、解决实际问题的能力,提高学生使用JAVA 进行项目开发及程序调试能力。
二、课程实训内容
利用《JAVA语言程序设计》及《Java Web开发》课程中所学到的编程知识和编程技巧,独立完成下列任务之一:
1、电子购物网站系统开发。
2、图书管理系统开发。
三、课程实训要求
1.对系统进行功能需求分析;
2.设计合理的数据结构和系统框架;
3.程序功能齐全,能正确运行;
4.课程实训完成后必须按要求提交课程实训报告。
四、实训过程
五、指导教师评语及成绩:。
【图书管理系统】【MainPro包】1.系统登录页面public class Login extends Frame {private static final long serialVersionUID = -1758475247807861408L;TextField text_user;TextField text_pass;public Login() {1 this.setTitle("登录");this.setLayout(null);//默认流式布局this.setSize(260, 170);/* 定义标签与文本框*/Label lbUser = new Label("用户名:");text_user = new TextField();Label lbPass = new Label("密码:");text_pass = new TextField();Button btn_ok = new Button("确定");Button btn_cancel = new Button("取消");lbUser.setBounds(40, 53, 60, 20);//x,y,width,heightlbPass.setBounds(40, 83, 60, 20);text_user.setBounds(100, 50, 120, 20);text_pass.setBounds(100, 80, 120, 20);btn_ok.setBounds(45, 120, 80, 25); // 确定按钮btn_cancel.setBounds(135, 120, 80, 25); // 取消按钮/* 添加标签与文本框*/add(lbUser);add(lbPass);add(text_user);add(text_pass);add(btn_ok);add(btn_cancel);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置this.setVisible(true); // 使窗体可见btn_ok.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {btn_okActionPerformed(e);//自定义确定按钮触发的实施过程}}));btn_cancel.addActionListener((new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}}));this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);} }); }public void btn_okActionPerformed(ActionEvent e) {String user = text_user.getText();String pass = text_pass.getText();String is_admin;// 如果用户名或密码任一为空,则终止后续操作if (user.equals("")||pass.equals("")) {JOptionPane.showMessageDialog(null, "用户名或密码不能为空!");return;}try {// 核对用户名和密码String sql = "select * from user where username=" + "'" + user + "' and password=" + "'" + pass + "'";ResultSet rs = DbOp.executeQuery(sql);// 如果此用户存在,则记录其状态(否:不是管理员,是:是管理员)if (rs.next()) {is_admin = rs.getString("is_admin");} else {JOptionPane.showMessageDialog(null, "用户名或密码不正确!");return;}GlobalVar.login_user = user; // 记录登录的用户名ShowMain show = new ShowMain(); // 调用主程序// 只有管理员才能使用"基础管理"和"借阅管理"菜单show.setRights(is_admin);// 释放窗体及其全部组件的屏幕资源,即使释放登录窗体dispose(); // 释放当前窗体} catch (SQLException e1) {JOptionPane.showMessageDialog(null, "用户数据库有误!");}}}2.系统首页页面public class ShowMain extends Frame {private static final long serialVersionUID = 5003296786441785470L;MenuBar menuBar;Menu jcwh, jcwh_book, jcwh_reader;//基础维护:图书维护、读者维护Menu jywh, cxgl, xtgl;//借阅维护、查询管理、系统管理MenuItemjcwh_book_add,jcwh_book_update,jcwh_book_delete,jcwh_reader_add,jcwh_reader_update,jcwh_reader_delete;MenuItem jywh_borrow, jywh_back;MenuItem cxgl_book, cxgl_reader;MenuItem xtgl_update_pass, xtgl_exit;public void setRights(String rights) {// 如果不是管理员,则禁止用户维护图书信息和读者信息以及禁止进行借阅管理,即只能查询if (rights.equals("否")) {jywh.setEnabled(false);jcwh.setEnabled(false);}}public ShowMain() {setTitle("图书管理系统");setLayout(new BorderLayout());setSize(640, 480);menuBar = new MenuBar();jcwh = new Menu("基础维护");// 基础维护菜单jcwh_book = new Menu("图书维护");// 图书维护菜单jcwh_book_add = new MenuItem("添加");// 添加图书菜单jcwh_book_update = new MenuItem("修改");// 修改图书菜单jcwh_book_delete = new MenuItem("删除");// 删除图书菜单jcwh_reader = new Menu("读者维护");// 读者维护菜单jcwh_reader_add = new MenuItem("添加读者");// 添加读者菜单jcwh_reader_update = new MenuItem("修改读者");jcwh_reader_delete = new MenuItem("删除读者");jywh = new Menu("借阅管理");jywh_borrow = new MenuItem("借书管理");jywh_back = new MenuItem("还书管理");cxgl = new Menu("查询管理");cxgl_book = new MenuItem("图书查询");cxgl_reader = new MenuItem("读者查询");xtgl = new Menu("系统管理");xtgl_update_pass = new MenuItem("修改密码");xtgl_exit = new MenuItem("退出系统");// 添加图书菜单jcwh_book.add(jcwh_book_add);jcwh_book.add(jcwh_book_update);jcwh_book.add(jcwh_book_delete);jcwh.add(jcwh_book);jcwh_reader.add(jcwh_reader_add);jcwh_reader.add(jcwh_reader_update);jcwh_reader.add(jcwh_reader_delete);jcwh.add(jcwh_reader);jywh.add(jywh_borrow);jywh.add(jywh_back);cxgl.add(cxgl_book);cxgl.add(cxgl_reader);xtgl.add(xtgl_update_pass);xtgl.add(xtgl_exit);menuBar.add(jcwh);menuBar.add(jywh);menuBar.add(cxgl);menuBar.add(xtgl);setMenuBar(menuBar);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见jcwh_book_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("save");} });jcwh_book_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("update");} });jcwh_book_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookManeger("delete");} });jcwh_reader_add.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("save");} });jcwh_reader_update.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("update");} });jcwh_reader_delete.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderManeger("delete");} });jywh_borrow.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Borrow();} });jywh_back.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new Back();} });cxgl_book.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new BookQuery();} });cxgl_reader.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new ReaderQuery();} });xtgl_update_pass.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {new UpdatePassword();} });xtgl_exit.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});this.addWindowListener(new WindowAdapter() {/* 关闭窗口*/// 重写windowClosing()方法public void windowClosing(WindowEvent e) {DbOp.Close(); // 关闭数据库System.exit(0);}});}}3.图书管理public class BookManeger extends JFrame {private static final long serialVersionUID = 377287301994613384L;private Label lbbookid_c = new Label("图书编号");private TextField tf_bookid_c = new TextField();private Label lbbookid = new Label("图书编号");private TextField tf_bookid = new TextField();private Label lbbookname = new Label("图书名称");private TextField tf_bookname = new TextField();private Label lbbooktype = new Label("图书类别");private Choice tf_booktype = new Choice();private Label lbauthor = new Label("作者");private TextField tf_author = new TextField();private Label lbtranslator = new Label("译者");private TextField tf_translator = new TextField();private Label lbpublisher = new Label("出版社");private TextField tf_publisher = new TextField();private Label lbpublish_time = new Label("出版时间");private TextField tf_publish_time = new TextField();private Label lbprice = new Label("定价");private TextField tf_price = new TextField();private Label lbstock = new Label("库存数量");private TextField tf_stock = new TextField();private Button queryBtn = new Button("查询");private Button saveBtn = new Button("保存");private Button closeBtn = new Button("关闭");private String optionStr;BookManeger(String str) {optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid);map.put("bookname", tf_bookname);map.put("booktype", tf_booktype);map.put("author", tf_author);map.put("translator", tf_translator);map.put("publisher", tf_publisher);map.put("publish_time", tf_publish_time);map.put("price", tf_price);map.put("stock", tf_stock);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delActionPerformed(e, map);}else{i = Jcwh.btn_saveActionPerformed(e, map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "图书添加成功!";}else if(optionStr.equals("update")){showInfo = "图书修改成功!";}else if(optionStr.equals("delete")){showInfo = "图书删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});/* 关闭窗口*/this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setSize(500, 320);lbbookid.setBounds(50, 40, 50, 20); // 图书编号tf_bookid.setBounds(110, 40, 100, 20);lbbookname.setBounds(240, 40, 50, 20); // 图书名称tf_bookname.setBounds(300, 40, 100, 20);lbbooktype.setBounds(50, 80, 50, 20); // 图书类别tf_booktype.setBounds(110, 80, 100, 20);tf_booktype.add("科技");tf_booktype.add("文学");tf_booktype.add("社科");tf_booktype.add("其他");lbauthor.setBounds(240, 80, 50, 20); // 作者tf_author.setBounds(300, 80, 100, 20);lbtranslator.setBounds(50, 120, 50, 20); // 设置译者tf_translator.setBounds(110, 120, 100, 20);lbpublisher.setBounds(240, 120, 50, 20); // 出版社tf_publisher.setBounds(300, 120, 100, 20);lbpublish_time.setBounds(50, 160, 50, 20); // 出版时间tf_publish_time.setBounds(110, 160, 100, 20);lbprice.setBounds(240, 160, 50, 20); // 定价tf_price.setBounds(300, 160, 100, 20);lbstock.setBounds(50, 200, 50, 20); // 库存数量tf_stock.setBounds(110, 200, 100, 20);saveBtn.setBounds(150, 240, 80, 25); // 保存按钮closeBtn.setBounds(280, 240, 80, 25);// 关闭按钮if(str.equals("save")){setTitle("添加图书");}else if(str.equals("update")){setTitle("修改图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbbookid_c.setBounds(100, 10, 50, 20); // 图书编号tf_bookid_c.setBounds(160, 10, 100, 20);tf_bookid.setEditable(false);//修改的图书信息中id不可以修改queryBtn.setBounds(280, 10, 80, 20); // 查询按钮add(lbbookid_c);add(tf_bookid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("bookid", tf_bookid_c);Book book = (Book)Jcwh.btn_queryActionPerformed(e,map).get("book");if(book!=null){tf_bookid.setText(book.getId());tf_bookname.setText(book.getBookname());// 将Choice的选定项设置为其名称等于指定字符串的项tf_booktype.select(book.getBooktype());tf_author.setText(book.getAuthor());tf_translator.setText(book.getTranslator());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf(book.getPrice()));tf_stock.setText(String.valueOf(book.getStock()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbbookid);add(tf_bookid);add(lbbookname);add(tf_bookname);add(lbbooktype);add(tf_booktype);add(lbauthor);add(tf_author);add(lbtranslator);add(tf_translator);add(lbpublisher);add(tf_publisher);add(lbpublish_time);add(tf_publish_time);add(lbprice);add(tf_price);add(lbstock);add(tf_stock);add(saveBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见}private void clearAllTextfield() {tf_bookid.setText("");tf_bookname.setText("");tf_author.setText("");tf_translator.setText("");tf_publisher.setText("");tf_publish_time.setText("");tf_price.setText("");tf_stock.setText("");}}4.读者管理public class ReaderManeger extends JFrame {private static final long serialVersionUID = -2399939451497711745L;Label lbreaderid_c = new Label("读者编号");TextField tf_readerid_c = new TextField();Label lbreaderid = new Label("读者编号");TextField tf_readerid = new TextField();Label lbreadername = new Label("读者姓名");TextField tf_readername = new TextField();Label lbreadertype = new Label("读者类别");Choice tf_readertype = new Choice();Label lbsex = new Label("性别");Choice tf_sex = new Choice();Label lbmax_num = new Label("可借数量");TextField tf_max_num = new TextField();Label lbdays_num = new Label("可借天数");TextField tf_days_num = new TextField();Button queryBtn = new Button("查询");Button saveBtn = new Button("保存");Button closeBtn = new Button("关闭");private String optionStr;//保存、修改、删除ReaderManeger(String str){optionStr = str;ggFrame(optionStr);saveBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid);map.put("readername", tf_readername);map.put("readertype", tf_readertype);map.put("sex", tf_sex);map.put("days_num", tf_days_num);map.put("max_num", tf_max_num);int i ;if(optionStr.equals("delete")){i = Jcwh.btn_delReaderActionPerformed(e, map);}else{i = Jcwh.btn_saveReaderActionPerformed(e,map,optionStr);}if (i == 1) {String showInfo = "";if(optionStr.equals("save")){showInfo = "读者添加成功!";}else if(optionStr.equals("update")){showInfo = "读者修改成功!";}else if(optionStr.equals("delete")){showInfo = "读者删除成功!";}JOptionPane.showMessageDialog(null, showInfo);// 清空全部文本框clearAllTextfield();}}});closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {dispose(); // 释放当前窗体}});this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) { // 关闭当前窗口dispose(); // 释放当前窗体}});}private void ggFrame(String str) {setLayout(null);setTitle("添加读者信息");setSize(500, 230);lbreaderid.setBounds(50, 50, 50, 20);tf_readerid.setBounds(110, 50, 100, 20);lbreadername.setBounds(240, 50, 50, 20);tf_readername.setBounds(300, 50, 100, 20);lbreadertype.setBounds(50, 80, 50, 20);tf_readertype.setBounds(110, 80, 100, 20);tf_readertype.add("教师");tf_readertype.add("学生");tf_readertype.add("职工");lbsex.setBounds(240, 80, 50, 20);tf_sex.setBounds(300, 80, 100, 20);tf_sex.add("男");tf_sex.add("女");lbmax_num.setBounds(50, 110, 50, 20);tf_max_num.setBounds(110, 110, 100, 20);lbdays_num.setBounds(240, 110, 50, 20);tf_days_num.setBounds(300, 110, 100, 20);saveBtn.setBounds(150, 150, 80, 25);closeBtn.setBounds(280, 150, 80, 25);if(str.equals("save")){setTitle("添加读者");}else if(str.equals("update")){setTitle("修改读者");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("修改");//将按钮显示文字修改成“修改”}else if(str.equals("delete")){setTitle("删除图书");lbreaderid_c.setBounds(100, 10, 50, 20);tf_readerid_c.setBounds(160, 10, 100, 20);tf_readerid.setEditable(false);queryBtn.setBounds(280, 10, 80, 20);add(lbreaderid_c);add(tf_readerid_c);add(queryBtn);queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) {HashMap<String, Object> map = new HashMap<String, Object>();map.put("readerid", tf_readerid_c);Reader reader = (Reader)Jcwh.btn_queryReaderActionPerformed(e,map).get("reader");if(reader!=null){tf_readerid.setText(reader.getId());tf_readername.setText(reader.getReadername());tf_readertype.select(reader.getReadertype());tf_sex.select(reader.getSex());tf_days_num.setText(String.valueOf(reader.getDays_num()));tf_max_num.setText(String.valueOf(reader.getMax_num()));}}});saveBtn.setLabel("删除");//将按钮显示文字修改成“删除”}add(lbreaderid);add(lbreadername);add(lbreadertype);add(lbsex);add(lbmax_num);add(lbdays_num);add(tf_readerid);add(tf_readername);add(tf_max_num);add(tf_days_num);add(tf_readertype);add(tf_sex);add(saveBtn);add(closeBtn);setLocationRelativeTo(null);setVisible(true);}private void clearAllTextfield() {tf_readerid.setText("");tf_readername.setText("");tf_max_num.setText("");tf_days_num.setText("");}public static void main(String[] args) {ReaderManeger r = new ReaderManeger("update");}}5.借书public class Borrow extends Frame {private static final long serialVersionUID = -1036076990599464079L;String SepLine = "-------------------------------------------------";Label lbbookid = new Label("图书编号");Label lbreaderid = new Label("读者编号");TextField tf_bookid = new TextField();TextField tf_readerid = new TextField();Button queryBtn = new Button("查询");Label lbbookinfo = new Label(SepLine + "图书信息" + SepLine); Label lbbookname = new Label("图书名称:");Label tf_bookname = new Label("xx");Label lbauthor = new Label("作者:");Label tf_author = new Label("xx");Label lbpublisher = new Label("出版社:");Label tf_publisher = new Label("xx");Label lbpublish_time = new Label("出版时间:");Label tf_publish_time = new Label("xx");Label lbprice = new Label("定价:");Label tf_price = new Label("xx");Label lbstock = new Label("库存数量:");Label tf_stock = new Label("xx");Label lbreaderinfo = new Label(SepLine + "读者信息" + SepLine); Label lbreadername = new Label("读者姓名:");Label tf_readername = new Label("xx");Label lbreadertype = new Label("读者类型:");Label tf_readertype = new Label("xx");Label lbmax_num = new Label("最大可借数:");Label tf_max_num = new Label("xx");Label lbdays_num = new Label("最大可借天数:");Label tf_days_num = new Label("xx");Label lbborrowinfo = new Label(SepLine + "借阅信息" + SepLine); Label lbborrowednum = new Label("该读者已借图书数量:"); Label tf_borrowednum = new Label("xx");Label lbif_borrow = new Label("该读者是否可借所选图书:"); Label tf_if_borrow = new Label("xx");Label lbborrow_date = new Label("借阅日期:");Label tf_borrow_date = new Label("xx");Button borrowBtn = new Button("借出");Button closeBtn = new Button("关闭");public Borrow() {setLayout(null);setTitle("借阅图书");setSize(500, 420);this.setForeground(Color.BLACK); // 设置前景色为黑色lbbookid.setBounds(30, 40, 50, 25); // 图书编号tf_bookid.setBounds(90, 40, 90, 20);lbreaderid.setBounds(200, 40, 50, 25); // 读者编号tf_readerid.setBounds(260, 40, 90, 20);queryBtn.setBounds(370, 40, 80, 25); // 查询按钮lbbookinfo.setBounds(30, 70, 440, 25); // 图书信息提示条lbbookname.setBounds(30, 100, 60, 25); // 图书名称tf_bookname.setBounds(90, 100, 200, 25);lbauthor.setBounds(310, 100, 60, 25); // 作者tf_author.setBounds(370, 100, 90, 25);lbpublisher.setBounds(30, 125, 60, 25); // 出版社tf_publisher.setBounds(90, 125, 200, 25);lbpublish_time.setBounds(310, 125, 60, 25); // 出版时间tf_publish_time.setBounds(370, 125, 90, 25);lbprice.setBounds(30, 150, 60, 25); // 定价tf_price.setBounds(90, 150, 200, 25);lbstock.setBounds(310, 150, 60, 25); // 库存数量tf_stock.setBounds(370, 150, 90, 25);lbreaderinfo.setBounds(30, 180, 440, 25); // 读者信息提示条lbreadername.setBounds(30, 205, 60, 25); // 读者姓名tf_readername.setBounds(90, 205, 90, 25);lbreadertype.setBounds(310, 205, 60, 25); // 读者类型tf_readertype.setBounds(370, 205, 90, 25);lbmax_num.setBounds(30, 230, 75, 25); // 最大可借数tf_max_num.setBounds(105, 230, 90, 25);lbdays_num.setBounds(310, 230, 85, 25); // 最大可借天数tf_days_num.setBounds(395, 230, 70, 25);lbborrowinfo.setBounds(30, 260, 440, 25); // 借阅信息提示条lbborrowednum.setBounds(30, 285, 120, 25);// 已借图书数量tf_borrowednum.setBounds(150, 285, 50, 25);lbif_borrow.setBounds(30, 310, 145, 25); // 是否可借tf_if_borrow.setBounds(175, 310, 50, 25);lbborrow_date.setBounds(30, 335, 60, 25);// 借书日期tf_borrow_date.setBounds(90, 335, 100, 25);borrowBtn.setBounds(160, 365, 80, 25);// 借出按钮borrowBtn.setEnabled(false); // 开始时禁用借出按钮closeBtn.setBounds(260, 365, 80, 25);// 关闭按钮queryBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_querywActionPerformed(e); } }); borrowBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { btn_borrowActionPerformed(e); } });closeBtn.addActionListener(new ActionListener() {public void actionPerformed(ActionEvent e) { setForeground(Color.BLACK); dispose(); } }); this.addWindowListener(new WindowAdapter() {public void windowClosing(WindowEvent e) {setForeground(Color.BLACK); // 设置前景色为黑色dispose(); // 关闭窗体}});add(lbbookid);add(lbreaderid);add(queryBtn);add(lbbookinfo);add(lbbookname);add(lbauthor);add(lbpublisher);add(lbpublish_time);add(lbprice);add(lbstock);add(lbreaderinfo);add(lbreadername);add(lbreadertype);add(lbmax_num);add(lbdays_num);add(lbborrowinfo);add(lbborrowednum);add(lbif_borrow);add(lbborrow_date);add(borrowBtn);add(closeBtn);setLocationRelativeTo(null); // 使窗体在屏幕上居中放置setVisible(true); // 使窗体可见setForeground(Color.RED); // 设置前景色为红色add(tf_bookid);add(tf_readerid);add(tf_bookname);add(tf_author);add(tf_publisher);add(tf_publish_time);add(tf_price);add(tf_stock);add(tf_readername);add(tf_readertype);add(tf_max_num);add(tf_days_num);add(tf_borrowednum);add(tf_if_borrow);add(tf_borrow_date);}// 图书和读者查询private void btn_querywActionPerformed(ActionEvent e) {String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();// 如果图书编号或读者编号两者均为空,或者有一个为空,则返回if (bookid.equals("") || readerid.equals("")) {JOptionPane.showMessageDialog(null, "图书编号和读者编号均不能为空!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询图书,结果存入book对象中Book book = BookSelect.SelectBookById(bookid);if (book != null) { // 如果查询到结果,将其显示在各文本框中tf_bookname.setText(book.getBookname());tf_author.setText(book.getAuthor());tf_publisher.setText(book.getPublisher());tf_publish_time.setText(book.getPublish_time().toString());tf_price.setText(String.valueOf((book.getPrice())));tf_stock.setText(String.valueOf(book.getStock()));} else {JOptionPane.showMessageDialog(null, "图书编号有误,查无此书!");init(); // 重新初始化各参数并禁止借出按钮return;}if (book.getStock() == 0) {JOptionPane.showMessageDialog(null, "图书已无库存,无法借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}// 按编号查询读者,结果存入reader对象中Reader reader = ReaderSelect.selectReaderById(readerid);// 如果查询到结果,将其显示在各文本框中if (reader != null) {tf_readername.setText(reader.getReadername());tf_readertype.setText(reader.getReadertype());tf_max_num.setText(String.valueOf(reader.getMax_num()));tf_days_num.setText(String.valueOf(reader.getDays_num()));} else {JOptionPane.showMessageDialog(null, "读者编号有误,查无此人!");init(); // 重新初始化各参数并禁止借出按钮return;}// 查询指定读者是否已借过指定图书且未归还if (IfBorrowBack.findbook(bookid, readerid)) {JOptionPane.showMessageDialog(null, "该读者已借阅所选图书,且未归还!");init(); // 重新初始化各参数并禁止借出按钮return;}// 统计读者所借图书数量int borrowednum = statborrowednum(readerid);tf_borrowednum.setText(String.valueOf(borrowednum));// 如果读者已借图书尚未超出其允许最大借书量,则允许其继续借阅所选图书if (borrowednum < reader.getMax_num()) {tf_if_borrow.setText("是");// 创建一个简单日期格式对象,注意:MM一定要用大写SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");// 创建日期变量,其内容为当前日期Date currentdate = new Date();// 将日期按指定格式输出String borrowdate = sdf.format(currentdate);tf_borrow_date.setText(borrowdate);borrowBtn.setEnabled(true); // 使借出按钮有效} else {JOptionPane.showMessageDialog(null, "该读者借书过多,无法继续借阅!");init(); // 重新初始化各参数并禁止借出按钮return;}}// 填写借出图书记录private void btn_borrowActionPerformed(ActionEvent e) {String sql;String bookid = tf_bookid.getText();String readerid = tf_readerid.getText();String borrowdate = tf_borrow_date.getText();// 为borrow表增加借书记录sql = "insert into borrow (book_id,reader_id,"+ "borrow_date,if_back) values('" + bookid + "','" + readerid + "','" + borrowdate + "','否')";。
本科毕业论文(设计)题目:社会管理一体化系统——图书管理模块姓名:学号:专业:院系:指导老师:职称学历:完成时间:本科毕业论文(设计)独创承诺书本人按照毕业论文(设计)进度计划积极开展实验(调查)研究活动,实事求是地做好实验(调查)记录,所呈交的毕业论文(设计)是我个人在导师指导下进行的研究工作及取得的研究成果。
据我所知,除文中特别加以标注引用参考文献资料外,论文(设计)中所有数据均为自己研究成果,不包含其他人已经发表或撰写过的研究成果。
与我一同工作的同志对本研究所做的工作已在论文中作了明确说明并表示谢意。
毕业论文(设计)作者签名:日期:社会管理一体化系统——图书管理模块摘要随着社会经济社会发展,实现社会一体化是我国科学发展观的必然要求,也是构建社会主义和谐社会的重要标志。
图书管理系统是现代城市建设信息化的必然产物。
由于图书种类的繁多,图书借阅的信息量大,需求量大,各个社区之间的图书种类与图书借阅又需要更好地协调与管理,方便读者也方便管理人员。
因此,在这种状况下,提供一种网络社区服务与管理系统对图书进行管理,使任何人在任何时候任何地点,都可以了解到图书的信息。
Struts、Spring和Hibernate是一个集成框架,是目前较流行的一种Web 应用程序开源框架。
本系统就是以Java Web为基础、SSH为底层框架实现对辖区的图书信息进行管理,包含的功能模块有图书信息模块、读者信息模块、图书借阅模块以及图书预警模块,权限设置方面采用了多用户多权限的方式,前台的交互方式本着简洁大方的原则,应用于社区,服务于社区。
关键词:社会一体化;图书管理;集成SSH框架;Java WebSocial integration system -- bookmanagement moduleAbstractWith the social and economic and social development, the realization of social integration is the inevitable requirement of view of scientific development of our country, and also an important symbol of the construction of socialist harmonious society.The community is the unit of society, community management and promoting the integrated development of society in a certain extent. Community management system is the inevitable product of the information construction of modern city. Due to the mobility of the city population is more and more frequent, the jurisdiction management content is more and more complex, the traditional management mode has been gradually unable to meet the needs of the old community management.The transformation of community management system will be the past passive coping with problems of management mode for the initiative to discover and solve problems.Struts, Spring and Hibernate is an integrated framework, is an open source Web application framework.This system is based on Java Web as the foundation, SSH as the underlying framework implementation of district personnel information management. Keywords:Social integration; Book management; SSH ; Java Web目录1 绪论 (1)1.1 研究的背景及意义 (1)1.1.1 研究的背景 (1)1.1.2 研究的目的与意义 (1)1.2 研究的主要内容 (2)1.3 本章小结 (2)2开发技术的介绍 (3)2.1 开发技术的介绍 (3)2.1.1 Java Web的介绍 (3)2.1.2 SSH框架的介绍 (3)2.1.3 MVC框架的介绍 (3)3 系统的需求分析和概要设计 (4)3.1 系统可行性分析 (4)3.1.1经济可行性 (4)3.1.2技术可行性 (4)3.1.3操作可行性 (4)3.2系统需求分析 (5)3.2.1系统需求功能概括 (5)3.2.2系统数据需求分析 (5)3.2.3系统功能模块分析 (6)3.3.1图书管理系统的系统目标 (6)3.3.2图书管理系统的功能结构 (6)3.3.3 数据库概念设计 (7)3.4本章小结 (10)4 系统的设计与实现 (11)4.1登录模块设计与实现 (11)4.1.1登录模块概述 (11)4.1.2 登录模块技术分析 (11)4.1.3 登录模块实现过程 (12)4.2管理模块概述 (13)4.2.1 图书管理模块概述 (13)4.2.2 图书管理模块的设计和实现过程 (13)4.2.3 图书信息管理模块的概述 (13)4.2.4 读者信息设置模块的概述 (14)4.2.5 借阅信息管理模块的概述 (15)4.2.6图书预警模块的概述 (15)4.2.7综合查询模块的概述 (16)4.3数据库设计 (17)4.4本章小结 (18)5 系统测试 (19)5.1 测试环境 (19)5.3测试结果 (20)5.4 本章小结 (24)6 研究结论与未来研究 (25)6.1 系统研究结论 (25)6.2 系统未来研究 (25)致谢 (26)参考文献 (27)1 绪论本章首先介绍了课题的研究背景、研究的目的与意义,其次对本文主要研究的内容进行了叙述。
实验报告模板实验报告课程名称高级Java程序设计实验项目基于MVC模式的Web 综合应用实验仪器____ 个人计算机__系别___计算机学院 ___专业__计算机科学与技术_____班级/学号____计科1204学生姓名____实验日期_ 2014/5/21-6/5_________成绩 _______________________指导教师 _____ _________目录第一章需求分析................................................................................................................ 第二章总体设计................................................................................................................2.1本系统的主要功能..................................................................................................2.2 Java源文件及其功能.............................................................................................2.3 项目构建思路........................................................................................................ 第三章模块功能介绍......................................................................................................... 第四章功能测试及运行效果............................................................................................... 参考文献............................................................................................................................ 工作总结............................................................................................................................第一章:需求分析任务1 开发图书馆管理信息系统项目需求:1.基于MVC模式开发该Java Web项目;2.本系统有两类用户角色,普通用户和管理员用户;3.普通用户:浏览图书信息,分类浏览,能够分别根据书名、作者、出版社为关键字查询图书;登陆后还可借阅图书;4. 管理员用户管理系统各项信息,包括:信息的添加、修改和删除。
5. 建立的图书类包含如下信息:编号、书名、作者、出版社、出版日期。
项目设计第二章:总体设计2.1本系统的主要功能:1、基于MVC模式开发该Java Web项目;2、本系统有两类用户角色,普通用户和管理员用户;3、普通用户:浏览图书信息,分类浏览,能够分别根据书名、作者、出版社为关键字查询图书;登陆后还可借阅图书;4、管理员用户管理系统各项信息,包括:信息的添加、修改和删除。
5、建立的图书类包含如下信息:编号、书名、作者、出版社、出版日期。
2.2 Java源文件及其功能(功能在下一章讲述):Ind ex.jsp<%-- Created by IntelliJ IDEA. --%><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head><title></title></head><body><center><h2>欢迎进入图书馆里系统!</h2><p><form method="post" action="/servlets/depend.do">普通用户<input type="radio" name="person" value="reader" checked><br>管理员用户<input type="radio" name="person" value="editer"><br>管理员密码<input type="password" name="password"><p><input type="submit" value="登录"></form></center></body></html>Manager.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-5-31Time: 下午3:59To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.ArrayList,bean.bookinfo" %><html><head><title></title></head><body><center><h2><a href="/add.jsp">添加图书</a></h2><table align="center" border="1" ><tr><font size="2" face="黑体" color="blue"><th>编号</th><th>书名</th><th>作者</th><th>出版社</th><th>出版日期</th><th colspan="2">管理</th></font></tr><%request.setCharacterEncoding("utf-8");ArrayList<bookinfo> list=(ArrayList<bookinfo>)request.getAttribute("list");for(bookinfo bi:list){String id=bi.getId();%><tr><td><%= bi.getId()%></td><td><%= bi.getName()%></td><td><%= bi.getAuthor()%></td><td><%= bi.getPress()%></td><td><%= bi.getDate()%></td> <td><a href="/servlets/edit.do?id=<%= id%>">修改</a></td><td><a href="/servlets/delete.do?id=<%= id%>">删除</a></td></tr><%}%></table></center></body></html>Read er.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-5-31Time: 下午3:59To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.ArrayList,bean.bookinfo" %><html><head><title></title></head><body><center><form action="/servlets/borrow.do" method="post"><table align="center" border="1" ><caption><h2>现有图书信息</h2></caption><p><tr><td colspan="6" align="right"><a href="/check.jsp">点击查询</a></td></tr><tr><font size="2" face="黑体" color="blue"> <th>编号</th><th>书名</th><th>作者</th><th>出版社</th><th>出版日期</th><th colspan="2">借阅</th></font> </tr><%request.setCharacterEncoding("utf-8");ArrayList<bookinfo> list=(ArrayList<bookinfo>)request.getAttribute("list");for(bookinfo bi:list){String id=bi.getId();%><tr><td><%= bi.getId()%></td><td><%= bi.getName()%></td><td><%= bi.getAuthor()%></td><td><%= bi.getPress()%></td><td><%= bi.getDate()%></td><td><input type="radio" name="borrow" value="123"></td><input type="hidden" name="id" value="<%= bi.getId()%>"></tr><%}%></table><p><input type="submit" value="提交"></form></center></body></html>Success.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-6-1Time: 下午1:34To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head><title></title></head><body><center><h2>操作成功</h2><br><a href="/servlets/list.do">浏览图书信息</a></center></body></html>Finalcheck.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-6-1Time: 下午4:15To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" import="bean.bookinfo" %><html><head><title></title></head><body><center><table align="center" border="1" ><tr><%request.setCharacterEncoding("utf-8");bookinfo bi=(bookinfo)request.getAttribute("bi");%><th>编号</th><th>书名</th><th>作者</th><th>出版社</th><th>出版日期</th></tr><tr><td><%= bi.getId()%></td><td><%= bi.getName()%></td><td><%= bi.getAuthor()%></td><td><%= bi.getPress()%></td><td><%= bi.getDate()%></td> </tr></table></center></body></html>Successread er.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-6-1Time: 下午1:34To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head><title></title></head><body><center><h2>操作成功</h2><br><a href="/servlets/listreader.do">浏览图书信息</a></center></body></html>Failure.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-6-1Time: 下午2:00To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head><title></title></head><body><center><h2>操作失败</h2><a href="javascript:history.back()">点击返回</a></center></body></html>Edit.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-5-31Time: 下午6:52To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" import="bean.bookinfo" %><html><head><title></title></head><body><% request.setCharacterEncoding("utf-8");bookinfo bi=(bookinfo)request.getAttribute("bi");%><center><form action="update.do" method="post"><input type="hidden" name="id" value="<%= bi.getId()%>"><table><h2><caption>修改信息</caption></h2><tr><th>书名</th><td><input type="text" value="<%= bi.getName()%>" name="name"> </td></tr><tr><th>作者</th><td><input type="text" value="<%= bi.getAuthor()%>" name="author"> </td></tr><tr><th>出版社</th><td><input type="text" value="<%= bi.getPress()%>" name="press"> </td></tr><tr><th>出版日期</th><td><input type="text" value="<%= bi.getDate()%>" name="date"> </td></tr><tr><td colspan="2" align="center"><input type="submit" value="提交"><input type="reset" value="重置"></td></tr></table></form></center></body></html>Check.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-5-31Time: 下午6:52To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" import="bean.bookinfo" %><html><head><title></title></head><body><% request.setCharacterEncoding("utf-8");bookinfo bi=(bookinfo)request.getAttribute("bi");%><center><form action="update.do" method="post"><input type="hidden" name="id" value="<%= bi.getId()%>"><table><h2><caption>修改信息</caption></h2><tr><th>书名</th><td><input type="text" value="<%= bi.getName()%>" name="name"> </td></tr><tr><th>作者</th><td><input type="text" value="<%= bi.getAuthor()%>" name="author"> </td></tr><tr><th>出版社</th><td><input type="text" value="<%= bi.getPress()%>" name="press"> </td></tr><tr><th>出版日期</th><td><input type="text" value="<%= bi.getDate()%>" name="date"> </td></tr><tr><td colspan="2" align="center"><input type="submit" value="提交"><input type="reset" value="重置"></td></tr></table></form></center></body></html>Add.jsp<%--Created by IntelliJ IDEA.User: AdministratorDate: 14-5-31Time: 下午7:20To change this template use File | Settings | File Templates.--%><%@ page contentType="text/html;charset=UTF-8" language="java" %><html><head><title></title></head><script language="JavaScript" src="common.js"></script><body><center><form name="form1" onsubmit="return check()" action="/servlets/add.do" method="post"> <table align="center" border="1"><h2><caption>图书信息</caption></h2><tr><th>编号</th><td><input type="text" name="id"> </td></tr><tr><th>书名</th><td><input type="text" name="name"> </td></tr><tr><th>作者</th><td><input type="text" name="author"> </td></tr><tr><th>出版社</th><td><input type="text" name="press"> </td></tr><tr><th>出版日期</th><td><input type="text" name="date"> </td></tr><tr><td colspan="2" align="center"><input type="submit" value="添加"><input type="reset" value="重置"></td></tr></table></form></center></body></html>Common.jsfunction check(){if(form1.id.value==""){alert ("no id!");form1.id.focus();return false;}if(.value==""){alert("no name!");.focus();return false;}if(form1.author.value==""){alert("no author!");form1.author.focus();return false;}if(form1.press.value==""){alert("no press!");form1.press.focus();return false;}if(form1.date.value==""){alert("no date!")form1.date.focus();return false;}}Bookinfo.javapackage bean;import ng.Exception;import ng.String;import ng.System;import java.sql.*;import java.sql.Connection;import java.sql.ResultSet;import java.sql.SQLException;import java.sql.Statement;import java.util.*;import java.util.ArrayList;public class bookinfo{private String id;private String name;private String author;private String press;private String date;public void setName(String name) { = name;}public String getName() {return name;}public void setAuthor(String author) {this.author = author;}public String getAuthor() {return author;}public void setDate(String date) {this.date = date;}public String getDate() {return date;}public void setPress(String press) {this.press = press;}public String getPress() {return press;}public void setId(String id) {this.id = id;}public String getId() {return id;}public static ArrayList<bookinfo> getbooklist(){ArrayList<bookinfo> list=new ArrayList<bookinfo>();String sql="select * from mvc_book";bean.dbbean jdbc=new bean.dbbean();ResultSet rs=jdbc.executeQuery(sql);try{while(rs.next()){bookinfo bi=new bookinfo();bi.setId(rs.getString("id"));bi.setName(rs.getString("name"));bi.setAuthor(rs.getString("author"));bi.setPress(rs.getString("press"));bi.setDate(rs.getString("date"));list.add(bi);}rs.close();}catch(SQLException e){e.printStackTrace();}jdbc.close();return list;}public static bookinfo getbookbyid(String id){String sql="select * from mvc_book where id="+id;dbbean jdbc=new dbbean();ResultSet rs=jdbc.executeQuery(sql);bookinfo bi = new bookinfo();try{if(rs.next()){bi.setDate(rs.getString("date"));bi.setPress(rs.getString("press"));bi.setAuthor(rs.getString("author"));bi.setName(rs.getString("name"));bi.setId(rs.getString("id"));}rs.close();}catch(SQLException e){System.out.println("no find");}jdbc.close();return bi;}public static int updatebook(String id,String name,String author,String press,String date){ int result=0;String sql="update mvc_book set name='"+name+"',author='"+author+"',press='"+press+"',date='"+date+"' where id="+id;dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;}public static int deletebook(String id){int result=0;String sql="delete from mvc_book where id="+id;dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;}public static int addbook(String id,String name,String author,String press,String date){int result=0;String sql="insert into mvc_book(id,name,author,press,date) values(id,'"+name+"','"+author+"','"+press+"','"+date+"')";dbbean jdbc=new dbbean();result=jdbc.executeUpdate(sql);return result;}}Dbbean.javapackage bean;import ng.Exception;import ng.String;import ng.System;import java.sql.*;import java.sql.Connection;import java.sql.ResultSet;import java.sql.Statement;public class dbbean{private String driverStr="com.mysql.jdbc.Driver";private String connStr="jdbc:mysql://localhost:3306/book?characterEncoding=utf-8";private String name="root";private String password="xyh201268";private Connection conn=null;private Statement stmt=null;public dbbean(){try{Class.forName(driverStr);conn=DriverManager.getConnection(connStr,name,password);stmt=conn.createStatement();}catch(Exception ex){System.out.println("no connect");}}public int executeUpdate(String s){int result=0;try{result=stmt.executeUpdate(s);}catch(Exception ex){System.out.println("update wrong!");}return result;}public ResultSet executeQuery(String s){ResultSet rs=null;try{rs=stmt.executeQuery(s);}catch(Exception ex){System.out.println("check wrong!");}return rs;}public void close(){try{stmt.close();conn.close();}catch(Exception ex){System.out.println("close!");}}}Servlet.javapackage servlets;import javax.servlet.ServletException;import javax.servlet.http.HttpServlet;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import java.io.IOException;import java.io.PrintWriter;import java.util.ArrayList;import bean.*;/*** Created by Administrator on 14-5-31.*/public class Servlet extends HttpServlet {protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {doPost(request, response);}protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {request.setCharacterEncoding("utf-8");String action=request.getServletPath();if(action.equals("/servlets/depend.do")){String value=request.getParameter("password");if(value.equals("123")){ArrayList<bean.bookinfo> list= bean.bookinfo.getbooklist();request.setAttribute("list", list);request.getRequestDispatcher("/manager.jsp").forward(request,response);}else{ ArrayList<bean.bookinfo> list= bean.bookinfo.getbooklist();request.setAttribute("list", list);request.getRequestDispatcher("/reader.jsp").forward(request,response);}}else if (action.equals("/servlets/list.do")){ArrayList<bean.bookinfo> list= bean.bookinfo.getbooklist();request.setAttribute("list", list);request.getRequestDispatcher("/manager.jsp").forward(request,response);}else if(action.equals("/servlets/edit.do")){String id =request.getParameter("id");bean.bookinfo bi= bean.bookinfo.getbookbyid(id);request.setAttribute("bi",bi);request.getRequestDispatcher("/edit.jsp").forward(request,response);}else if(action.equals("/servlets/update.do")){String id=request.getParameter("id");String name=request.getParameter("name");String author=request.getParameter("author");String press=request.getParameter("press");String date=request.getParameter("date");int r= bean.bookinfo.updatebook(id, name, author, press, date);if (r==1){request.getRequestDispatcher("/success.jsp").forward(request,response);}else{request.getRequestDispatcher("/failure.jsp").forward(request,response);}}else if (action.equals("/servlets/delete.do")){String id=request.getParameter("id");int r= bean.bookinfo.deletebook(id);if (r==1){request.getRequestDispatcher("/success.jsp").forward(request,response);}else{request.getRequestDispatcher("/failure.jsp").forward(request,response);}}else if (action.equals("/servlets/add.do")){String id=request.getParameter("id");String name=request.getParameter("name");String author=request.getParameter("author");String press=request.getParameter("press");String date=request.getParameter("date");int r= bean.bookinfo.addbook(id, name, author, press, date);if (r==1){request.getRequestDispatcher("/success.jsp").forward(request,response);}else{request.getRequestDispatcher("/failure.jsp").forward(request,response);}}else if (action.equals("/servlets/borrow.do")){String borrow=request.getParameter("borrow");if(borrow.equals("123")){String id=request.getParameter("id");int r= bean.bookinfo.deletebook(id);if (r==1){request.getRequestDispatcher("/success.jsp").forward(request,response);}else{request.getRequestDispatcher("/failure.jsp").forward(request,response);}}}else if (action.equals("/servlets/check.do")){String id=request.getParameter("id");bean.bookinfo bi= bean.bookinfo.getbookbyid(id);request.setAttribute("bi",bi);request.getRequestDispatcher("/finalcheck.jsp").forward(request,response);}}}2.3 项目构建思路:1、主界面有两条通道,管理员必须要有密码才能进入管理员页面,管理员页面具有修改,删除,添加等功能,而普通用户则具有借阅图书(我这边的借阅图书,相当于删除,没有后续的功能),按编号查询图书信息等功能。