基于SSM框架开发的图书管理系统

基于SSM框架开发的图书管理系统

    • 项目需求
    • 数据库设计
    • 图书管理数据库代码
    • 建立一个普通的JavaWeb项目
      • 首先创建动态web项目
      • 导入spring+MyBatis+SpringMVC的jar包文件
      • 配置Web.xml文件
      • 配置C3p0数据源,在c3p0-config.xml文件中进行配置
      • 配置MyBatis.xml
      • 配置applicationContext.xml文件(最核心的文件)
      • 建立pojo包,在里面编写对应的数据库表中的字段实体
      • 建立Util工具类,在里面编写分页工具
      • 建立Dao包在里面建立相应的接口和xml文件。
      • 建立Service层,在里面调用Dao层接口方法并返回对象的方法函数
      • 创建Controller层,在里面编写对应的实现方法。通过注解来注入,使其代码更加简单简写,减少了不必要的代码的编写。
      • 相关的jsp界面内容如下

项目需求

  • 需求描述:
    ⽤户分为两种⻆⾊:管理员和读者;
    ⽤户管理模块:管理员可以添加读者⽤户,可以查阅读者⽤户列表,可以修改读者⽤户
    信息;
    图书管理模块:管理员⽤户可以对图书信息进⾏CRUD操作;
    借阅管理模块:管理员⽤户管理每个⽤户的借书信息,根据读者每次的借书情况,维护
    ⽤户借书记录信息,借阅信息列表必须包含的列:⽤户名,身份证号,书名,出版社,
    图书作者,出版⽇期,借阅数量,借出⽇期,归还⽇期(如果还未归还,此处不显示归
    还⽇期,可以显示字样:“未归还”);
    读者⽤户登陆系统,只能看到⾃⼰的借阅信息;
    开发完成,在数据库中直接添加管理员⽤户数据和读者⽤户数据,⽆需开发注册功能;
    需要在数据库中增加⼏条图书信息⽤于测试。

数据库设计

角色表(role)

字段名 含义
id 主键
Role_name ⻆⾊名
Status ⻆⾊状态(0-正常,1-禁⽤)

⽤户表(user)

字段名 含义
id 主键
User_name ⽤户名,⽤于登陆
password 密码,⽤于登陆
id_no 身份证号
Real_name ⽤户姓名
status ⽤户状态(0:正常,1:挂失,-1:锁定)
Role_id 外键,关联⻆⾊表

⽤户借书记录表(user_borrow_record)

字段名 含义
id 主键
User_id 外键,关联⽤户表
Book_id 外键,关联图书信息表
Borrow_count 借阅数量(共借阅⼏本书)
Borrow_date 借出⽇期
Return_date 归还⽇期

图书信息表(book_info):

字段名 含义
id 主键
Book_name 书名
Press_name 出版社名称
Author_name 作者名
Pub_date 出版⽇期

图书管理数据库代码

DROP TABLE IF EXISTS `book`;
CREATE TABLE `book`  (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `Book_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Press_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Author_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Pub_date` date DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 6 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of book
-- ----------------------------
INSERT INTO `book` VALUES (1, '骆驼祥子', '清华出版社', '老舍', '2020-10-28');
INSERT INTO `book` VALUES (2, '倚天屠龙记', '人民大学出版社', '金庸', '2020-10-06');
INSERT INTO `book` VALUES (3, '天涯 明月刀', '人民邮电出版社', '天宇', '2020-10-06');
INSERT INTO `book` VALUES (4, '盗墓笔记', '中国文学出版社', '南派三叔', '2020-10-27');

-- ----------------------------
-- Table structure for borrow
-- ----------------------------
DROP TABLE IF EXISTS `borrow`;
CREATE TABLE `borrow`  (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `User_id` int(20) DEFAULT NULL,
  `Book_id` int(20) DEFAULT NULL,
  `Borrow_count` int(30) DEFAULT NULL,
  `Borrow_date` date DEFAULT NULL,
  `Return_date` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `user_id`(`User_id`) USING BTREE,
  INDEX `book_id`(`Book_id`) USING BTREE,
  CONSTRAINT `book_id` FOREIGN KEY (`Book_id`) REFERENCES `book` (`id`) ON DELETE SET NULL ON UPDATE CASCADE,
  CONSTRAINT `user_id` FOREIGN KEY (`User_id`) REFERENCES `user` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of borrow
-- ----------------------------
INSERT INTO `borrow` VALUES (1, 1, 1, 1, '2020-10-14', '2020-10-30');
INSERT INTO `borrow` VALUES (2, 2, 2, 3, '2020-10-07', NULL);
INSERT INTO `borrow` VALUES (4, 3, 3, 6, '2020-10-31', '未归还');
INSERT INTO `borrow` VALUES (5, 2, 1, 6, '2020-10-31', '2020-10-31');
INSERT INTO `borrow` VALUES (6, 2, 1, 6, '2020-10-31', '2020-10-31');

-- ----------------------------
-- Table structure for role
-- ----------------------------
DROP TABLE IF EXISTS `role`;
CREATE TABLE `role`  (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `Role_name` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Status` char(1) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 4 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of role
-- ----------------------------
INSERT INTO `role` VALUES (1, '管理员', '0');
INSERT INTO `role` VALUES (2, '读者', '0');

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user`  (
  `id` int(20) NOT NULL AUTO_INCREMENT,
  `User_name` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `id_no` varchar(45) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Real_name` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `status` char(3) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL,
  `Role_id` int(20) DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `role_id`(`Role_id`) USING BTREE,
  CONSTRAINT `role_id` FOREIGN KEY (`Role_id`) REFERENCES `role` (`id`) ON DELETE SET NULL ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 5 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of user
-- ----------------------------
INSERT INTO `user` VALUES (1, 'admin', '123456', '370782133312061211', '张三', '0', 1);
INSERT INTO `user` VALUES (2, '李四', '123456', '370785159812141210', '张柳', '0', 2);
INSERT INTO `user` VALUES (3, 'abc', '123', '1151566', '李四', '0', 2);

SET FOREIGN_KEY_CHECKS = 1;

建立一个普通的JavaWeb项目

  1. new---->file------>Dynamic Web Project

首先创建动态web项目

基于SSM框架开发的图书管理系统_第1张图片

导入spring+MyBatis+SpringMVC的jar包文件

基于SSM框架开发的图书管理系统_第2张图片

配置Web.xml文件

<!-- 配置核心调度器 -->
  <servlet>
		<servlet-name>SpringMVC</servlet-name>
		<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
		<!-- 加载Spring配置文件 -->
		<init-param> 
			<param-name>contextConfigLocation</param-name> 
			<param-value>classpath:applictionContext.xml</param-value> 
		</init-param> 
		<load-on-startup>1</load-on-startup>
	</servlet>

	<servlet-mapping>
		<servlet-name>SpringMVC</servlet-name>
		<!--配置可以被核心调度器拦截的请求资源后缀 -->
		<url-pattern>*.do</url-pattern>
	</servlet-mapping>
	
	<!-- 编码过滤器 -->
	<filter>
		<filter-name>characterEncodingFilter</filter-name>
		<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
	<filter-mapping>
		<filter-name>characterEncodingFilter</filter-name>
		<url-pattern>/*
	

配置C3p0数据源,在c3p0-config.xml文件中进行配置

<?xml version="1.0" encoding="UTF-8"?>
<c3p0-config>
	<!-- 这是默认配置信息 -->
	<default-config>
		<property name="jdbcUrl">
			jdbc:mysql://localhost:3306/booklibrary?characterEncoding=utf-8
		</property>
		<property name="driverClass">
			com.mysql.jdbc.Driver
		</property>
		<property name="user">root</property>
		<property name="password">1234567</property>
		<property name="acquireIncrement">3</property>
		<property name="initialPoolSize">10</property>
		<property name="minPoolSize">2</property>
		<property name="maxPoolSize">10</property>
	</default-config>
</c3p0-config>

配置MyBatis.xml

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
	<!-- 起别名 -->
	<typeAliases>
		<package name="com.lipeiyu.pojo"/>
	</typeAliases>
</configuration>

配置applicationContext.xml文件(最核心的文件)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:context="http://www.springframework.org/schema/context"
	xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:mvc="http://www.springframework.org/schema/mvc"
	xsi:schemaLocation="
    	http://www.springframework.org/schema/beans
        https://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/aop
        http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/tx
        http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc.xsd">

	<!-- 1.配置注解扫描器 -->
	<context:component-scan
		base-package="com.lipeiyu"></context:component-scan>

	<!-- 2.配置 C3P0数据源 -->
	<bean id="datasource"
		class="com.mchange.v2.c3p0.ComboPooledDataSource"></bean>

	<!-- 3.让Spring管理SQLSessionFactory这就是MyBatis提供的整合Spring包里面最核心的类 -->
	<bean id="sqlSessionFactory"
		class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 配置数据源 -->
		<property name="dataSource" ref="datasource"></property>
		<!-- MyBatis的核心配置文件 -->
		<property name="configLocation" value="classpath:MyBatis.xml"></property>
	</bean>

	<!-- 4.配置Mapper,自动扫描 将Mapper接口生成代理对象注入到Spring -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.lipeiyu.dao"></property>
		<property name="sqlSessionFactoryBeanName"
			value="sqlSessionFactory"></property>
	</bean>

	<!-- 5.配置SpringMVC内部视图解析器 -->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/"></property>
		<property name="suffix" value=".jsp"></property>
		<property name="order" value="5"></property>
	</bean>
</beans>

建立pojo包,在里面编写对应的数据库表中的字段实体

角色实体

package com.lipeiyu.pojo;

import java.io.Serializable;

public class Role implements Serializable{
     
	
	private static final long serialVersionUID = 1L;
	
	private int id;
	private String role_name;
	private String status;
	
	public int getId() {
     
		return id;
	}
	
	public void setId(int id) {
     
		this.id = id;
	}
	
	public String getRole_name() {
     
		return role_name;
	}
	
	public void setRole_name(String role_name) {
     
		this.role_name = role_name;
	}
	
	public String getStatus() {
     
		return status;
	}
	
	public void setStatus(String status) {
     
		this.status = status;
	}
	
	public Role() {
     
		super();
		// TODO Auto-generated constructor stub
	}
	
	public Role(int id, String role_name, String status) {
     
		super();
		this.id = id;
		this.role_name = role_name;
		this.status = status;
	}
	
	@Override
	public String toString() {
     
		return "Role [id=" + id + ", role_name=" + role_name + ", status=" + status + "]";
	}
	


}

图书实体

package com.lipeiyu.pojo;

import java.io.Serializable;

public class Book implements Serializable{
     

	private static final long serialVersionUID = 1L;
	private int id;
	private String book_name;
	private String press_name;
	private String author_name;
	private String pub_date;
	public int getId() {
     
		return id;
	}
	public void setId(int id) {
     
		this.id = id;
	}
	public String getBook_name() {
     
		return book_name;
	}
	public void setBook_name(String book_name) {
     
		this.book_name = book_name;
	}
	public String getPress_name() {
     
		return press_name;
	}
	public void setPress_name(String press_name) {
     
		this.press_name = press_name;
	}
	public String getAuthor_name() {
     
		return author_name;
	}
	public void setAuthor_name(String author_name) {
     
		this.author_name = author_name;
	}
	public String getPub_date() {
     
		return pub_date;
	}
	public void setPub_date(String pub_date) {
     
		this.pub_date = pub_date;
	}
	public Book() {
     
		super();
		// TODO Auto-generated constructor stub
	}
	public Book(int id, String book_name, String press_name, String author_name, String pub_date) {
     
		super();
		this.id = id;
		this.book_name = book_name;
		this.press_name = press_name;
		this.author_name = author_name;
		this.pub_date = pub_date;
	}
	@Override
	public String toString() {
     
		return "Book_info [id=" + id + ", book_name=" + book_name + ", press_name=" + press_name + ", author_name="
				+ author_name + ", pub_date=" + pub_date + "]";
	}
	
	


}

用户实体

package com.lipeiyu.pojo;

import java.io.Serializable;

public class User implements Serializable{
     
	private static final long serialVersionUID = 1L;
	
	private int id;
	private String user_name;
	private String password;
	private String  id_no;
	private String real_name;
	private String status;
	private int role_id;
	private Role role;
	
	
	public Role getRole() {
     
		return role;
	}
	public void setRole(Role role) {
     
		this.role = role;
	}
	public int getId() {
     
		return id;
	}
	public void setId(int id) {
     
		this.id = id;
	}
	public String getUser_name() {
     
		return user_name;
	}
	public void setUser_name(String user_name) {
     
		this.user_name = user_name;
	}
	public String getPassword() {
     
		return password;
	}
	public void setPassword(String password) {
     
		this.password = password;
	}
	public String getId_no() {
     
		return id_no;
	}
	public void setId_no(String id_no) {
     
		this.id_no = id_no;
	}
	public String getReal_name() {
     
		return real_name;
	}
	public void setReal_name(String real_name) {
     
		this.real_name = real_name;
	}
	public String getStatus() {
     
		return status;
	}
	public void setStatus(String status) {
     
		this.status = status;
	}
	public int getRole_id() {
     
		return role_id;
	}
	public void setRole_id(int role_id) {
     
		this.role_id = role_id;
	}
	public User() {
     
		super();
		// TODO Auto-generated constructor stub
	}
	public User(int id, String user_name, String password, String id_no, String real_name, String status, int role_id) {
     
		super();
		this.id = id;
		this.user_name = user_name;
		this.password = password;
		this.id_no = id_no;
		this.real_name = real_name;
		this.status = status;
		this.role_id = role_id;
	}
	@Override
	public String toString() {
     
		return "User [id=" + id + ", user_name=" + user_name + ", password=" + password + ", id_no=" + id_no
				+ ", real_name=" + real_name + ", status=" + status + ", role_id=" + role_id + ", role=" + role + "]";
	}
	
	


}

借阅信息实体

package com.lipeiyu.pojo;

import java.io.Serializable;
import java.util.List;

public class Borrow implements Serializable {
     

	private static final long serialVersionUID = 1L;
	
	private int id;
	private int user_id;
	private int book_id;
	private int borrow_count;
	private String borrow_date;
	private String return_date;
	
	private User user;
	private Book book;
	
	public User getUser() {
     
		return user;
	}
	public void setUser(User user) {
     
		this.user = user;
	}
	public Book getBook() {
     
		return book;
	}
	public void setBook(Book book) {
     
		this.book = book;
	}
	public int getId() {
     
		return id;
	}
	public void setId(int id) {
     
		this.id = id;
	}
	public int getUser_id() {
     
		return user_id;
	}
	public void setUser_id(int user_id) {
     
		this.user_id = user_id;
	}
	public int getBook_id() {
     
		return book_id;
	}
	public void setBook_id(int book_id) {
     
		this.book_id = book_id;
	}
	public int getBorrow_count() {
     
		return borrow_count;
	}
	public void setBorrow_count(int borrow_count) {
     
		this.borrow_count = borrow_count;
	}
	public String getBorrow_date() {
     
		return borrow_date;
	}
	public void setBorrow_date(String borrow_date) {
     
		this.borrow_date = borrow_date;
	}
	public String getReturn_date() {
     
		return return_date;
	}
	public void setReturn_date(String return_date) {
     
		this.return_date = return_date;
	}
	public Borrow() {
     
		super();
		// TODO Auto-generated constructor stub
	}
	public Borrow(int id, int user_id, int book_id, int borrow_count, String borrow_date,
			String return_date) {
     
		super();
		this.id = id;
		this.user_id = user_id;
		this.book_id = book_id;
		this.borrow_count = borrow_count;
		this.borrow_date = borrow_date;
		this.return_date = return_date;
	}
	
	
	public Borrow(int id, int user_id, int book_id, int borrow_count, String borrow_date, String return_date, User user,
			Book book) {
     
		super();
		this.id = id;
		this.user_id = user_id;
		this.book_id = book_id;
		this.borrow_count = borrow_count;
		this.borrow_date = borrow_date;
		this.return_date = return_date;
		this.user = user;
		this.book = book;
	}
	@Override
	public String toString() {
     
		return "Borrow [id=" + id + ", user_id=" + user_id + ", book_id=" + book_id + ", borrow_count=" + borrow_count
				+ ", borrow_date=" + borrow_date + ", return_date=" + return_date + ", user=" + user + ", book=" + book
				+ "]";
	}
	
	


}

建立Util工具类,在里面编写分页工具

package com.lipeiyu.util;
/**
 * 分页工具类
 * @author Lenovo
 *
 */
public class PageUtil {
     
	private int totalCount;//总笔数,这个数据一共有多少笔  get/set
	private int pageSize;//每页有多少笔数据 get/set
	private int totalPageCount;//总共有多少页数据 get
	private int currentPageIndex;//当前是第多少页 get/set
	private int startIndex;//从第几笔开始查询数据 get
	//total不需要做处理
	public int getTotalCount() {
     
		return totalCount;
	}
	public void setTotalCount(int totalCount) {
     
		//totalPageCount总笔数需要重新计算,因为发生改变需要重新计算
		//因为totalCount发生变化,总页数就会发生变化
		this.totalPageCount = (totalCount + this.pageSize-1) / this.pageSize;
		this.totalCount = totalCount;
	}
	public int getPageSize() {
     
		return pageSize;
	}
	//每页几笔数据
	//pageSize发生变化?水变化!总页数,每页从第几笔开始查询
	public void setPageSize(int pageSize) {
     
		//this是当前对象的引用,调用本类的构造函数
		this.totalPageCount = (this.totalCount + pageSize-1) / pageSize;
		this.startIndex = this.currentPageIndex * pageSize;
		this.pageSize = pageSize;
	}
	//需要计算得到 totalPageCount = (totalCount + pageSize -1 )/pageSize;
	public int getTotalPageCount() {
     
		return (this.totalCount + this.pageSize-1) / this.pageSize;
	}
	
	public int getCurrentPageIndex() {
     
		return currentPageIndex;
	}
	public void setCurrentPageIndex(int currentPageIndex) {
     
		//当前是第几笔,如果他变化了,会引起谁变化?this.startIndex = currentPageIndex * this.pageSize;
		this.startIndex = currentPageIndex * this.pageSize;
		this.currentPageIndex = currentPageIndex;
	}
	//从第几笔查询
	public int getStartIndex() {
     
		return this.currentPageIndex * this.pageSize;
	}
	//构造函数
	public PageUtil() {
     
		//this调用本类的构造函数
		this(0,5,0);
}
	public PageUtil(int totalCount, int pageSize, int currentPageIndex) {
     
		super();
		this.totalCount = totalCount;
		this.pageSize = pageSize;
		this.currentPageIndex = currentPageIndex;
		//手动计算初始化其他可变的变量
		this.totalPageCount = (this.totalCount + this.pageSize-1) / this.pageSize;
		this.startIndex = this.currentPageIndex * this.pageSize;
	}
	
	@Override
	public String toString() {
     
		return "PageUtil [totalCount=" + totalCount + ", pageSize=" + pageSize + ", totalPageCount=" + totalPageCount
				+ ", currentPageIndex=" + currentPageIndex + ", startIndex=" + startIndex + "]";
	}
	public static void main(String[] args) {
     
		//测试
		PageUtil pageUtil = new PageUtil(10,3, 1);
		System.out.println(pageUtil.toString());
		pageUtil.setTotalCount(20);
		System.out.println(pageUtil.toString());
		pageUtil.setPageSize(6);
		System.out.println(pageUtil.toString());
	}
	
	
	
	
	
}

建立Dao包在里面建立相应的接口和xml文件。

  • 接口:编写增删改查的方法
  • xml文件:编写增删改查的SQL语句
    Role接口
package com.lipeiyu.dao;

import java.util.List;

import com.lipeiyu.pojo.Role;

public interface IRoleDAO {
     
	
	//查询所有
	public List<Role> queryAll();
	

}

RoleDAO.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lipeiyu.dao.IRoleDAO">

	<select id="queryAll" resultType="Role">
	 	select * from role
	</select>
</mapper>

BookDao接口

package com.lipeiyu.dao;

import java.util.List;
import java.util.Map;

import com.lipeiyu.pojo.Book;

public interface IBookDAO {
     
	
	public List<Book> queryAll(Map<String,Integer> map);
	
	public int getCount();
	
	public int add(Book book);
	
	public int delete(int id);
	
	public Book queryByPK(int id);
	
	public int update(Book book);
	
	public List<Book> queryAllb();
}

BookDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lipeiyu.dao.IBookDAO">

	<select id="queryAll" resultType="Book">
		SELECT * FROM book limit #{
     startIndex},#{
     pageSize}
	</select>
	
	<insert id="add" parameterType="Book">
		insert into book(Book_name,Press_name,Author_name,Pub_date) 
		values(#{
     book_name},#{
     press_name},#{
     author_name},#{
     pub_date})
	</insert>
	
	<delete id="delete" parameterType="_int">
		delete from Book where id = #{
     id}
	</delete>
	
	<select id="queryByPK" resultType="Book" parameterType="int">
		select * from book where id = #{
     id}
	</select>
	
	<update id="update" parameterType="Book">
		update book set Book_name=#{
     book_name} , Press_name=#{
     press_name} , 
		Author_name=#{
     author_name} , Pub_date=#{
     pub_date} where id = #{
     id}
	</update>
	
	<select id="getCount" resultType="int">
		select count(*) from book
	</select>
	
	<select id="queryAllb" resultType="Book">
		select * from book
	</select>
</mapper>

User接口

package com.lipeiyu.dao;

import java.util.List;
import java.util.Map;

import com.lipeiyu.pojo.User;

public interface IUserDAO {
     
	
	//登录
	public User queryByKeywords(Map<String,Object> map);
	
	//添加
	public int add(User user);
	
	//删除
	public int delete(int id);
	
	//编辑
	public User queryByPK(int id);
	
	//修改
	public int update(User user);
	
	//查询所有分页
	public List<User> queryAll(Map<String,Integer> map);
	
	//查询总数
	public int getCount();
	
	public List<User> queryAllu();

}

UserDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lipeiyu.dao.IUserDAO">

	<select id="queryByKeywords" resultType="User" parameterType="map">
		select * from user where User_name = #{
     user_name} and password = #{
     password} 
	</select>
	
	<insert id="add" parameterType="User">
		insert into user(User_name,password,id_no,Real_name,status,Role_id) 
 	 	values(#{
     user_name},#{
     password},#{
     id_no},#{
     real_name},#{
     status},#{
     role_id})
	</insert>
	
	<delete id="delete" parameterType="_int">
		delete from user where id = #{
     id}
	</delete>
	
	<select id="queryByPK" resultMap="Map1to1" parameterType="int">
		select * from user where id = #{
     id}
	</select>
	
	<resultMap type="User" id="Map1to1">
 	<id column="id" property="id"></id>
 	<result column="User_name" property="user_name"/>
 	<result column="password" property="password"/>
 	<result column="id_no" property="id_no"/>
 	<result column="Real_name" property="real_name"/>
 	<result column="status" property="status"/>
 	<result column="Role_id" property="role_id"/>
 		<association property="role" javaType="Role">
 			<id property="id" column="id"/>
 		<result property="role_name" column="Role_name"/>
 		</association>
 	</resultMap>
	<select id="queryAll" resultMap="Map1to1" parameterType="map">
		select user.*,role.Role_name from user LEFT OUTER JOIN 
		role on user.Role_id = role.id order by user.id ASC,user.role_id DESC limit #{
     startIndex},#{
     pageSize}
	</select>
	
	<update id="update" parameterType="User">
		update user set User_name=#{
     user_name} , password=#{
     password} , id_no=#{
     id_no} , Real_name=#{
     real_name} , 
		status=#{
     status} , Role_id=#{
     role_id} where id=#{
     id}
	</update>
	
	<select id="getCount" resultType="int">
		select count(*) from user
	</select>
	
	<select id="queryAllu" resultType="User">
		select * from user
	</select>
</mapper>

Borrow接口

package com.lipeiyu.dao;

import java.util.List;
import java.util.Map;

import com.lipeiyu.pojo.Borrow;

public interface IBorrowDAO {
     
	
	//查询借阅信息
	public List<Borrow> queryAll();
	
	//添加
	public int add(Borrow borrow);
	
	//删除
	public int delete(int id);
	
	//模糊查询
	public List<Borrow> queryByKeyWords(Map<String,Object> map);
	
	//修改
	public int update(Borrow borrow);
	
	//根据主键查询
	public Borrow queryByPK(int id);

}

BorrowDao.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.lipeiyu.dao.IBorrowDAO">

	<resultMap type="Borrow" id="Map1to1">
		<id column="id" property="id"/>
		<result column="User_id" property="user_id" />
		<result column="Book_id" property="book_id" />
		<result column="Borrow_count" property="borrow_count" />
		<result column="Borrow_date" property="borrow_date" />
		<result column="Return_date" property="return_date" />
		<association property="book" javaType="Book">
			<id column="id" property="id"/>
			<result column="Book_name" property="book_name"/>
			<result column="Press_name" property="press_name"/>
			<result column="Author_name" property="author_name"/>
			<result column="Pub_date" property="pub_date"/>
		</association>
		<association property="user" javaType="User">
			<id column="id" property="id"/>
			<result column="User_name" property="user_name"/>
			<result column="id_no" property="id_no"/>
		</association>
	</resultMap>
	
	<select id="queryAll" resultMap="Map1to1">
		SELECT borrow.id, user.User_name,user.id_no,book.Author_name,
		book.Pub_date,book.Book_name,book.Press_name,book.Pub_date,
		borrow.Borrow_count,borrow.Borrow_date,borrow.Return_date 
		from borrow LEFT outer join book on book.id = borrow.Book_id 
		LEFT OUTER JOIN user on user.id = borrow.User_id
	</select>
	
	<insert id="add" parameterType="Borrow">
		insert into borrow(User_id,Book_id,Borrow_count,Borrow_date,Return_date) 
		values(#{
     user_id},#{
     book_id},#{
     borrow_count},#{
     borrow_date},#{
     return_date})
	</insert>
	
	<delete id="delete" parameterType="int">
		delete from borrow where id = #{
     id}
	</delete>
	
	<select id="queryByKeyWords" resultMap="Map1to1" parameterType="map">
		SELECT borrow.id, user.User_name,user.id_no,book.Author_name,
		book.Pub_date,book.Book_name,book.Press_name,book.Pub_date,
		borrow.Borrow_count,borrow.Borrow_date,borrow.Return_date 
		from borrow LEFT outer join book on book.id = borrow.Book_id 
		LEFT OUTER JOIN user on user.id = borrow.User_id
		<where>
			<if test="user_id != null and user_id != '' and user_id !='0'">
				and User_id = #{
     user_id}
			</if>
			<if test="book_id != null and book_id != '' and book_id !='0'">
				and Book_id = #{
     book_id}
			</if>
			<if test="borrow_date != null and borrow_date != ''">
				and Borrow_date = #{
     borrow_date}
			</if>
			<if test="return_date != null and return_date != ''">
				and Return_date = #{
     return_date}
			</if>
		</where>
	</select>
	
	<select id="queryByPK" parameterType="int" resultMap="Map1to1">
		select * from borrow where id = #{
     id}
	</select>
	
	<update id="update" parameterType="Borrow">
	 	update borrow set Return_date = #{
     return_date} where id = #{
     id}
	 </update>
</mapper>

建立Service层,在里面调用Dao层接口方法并返回对象的方法函数

RoleService

package com.lipeiyu.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lipeiyu.dao.IRoleDAO;
import com.lipeiyu.pojo.Role;

@Service
public class RoleService {
     
	
	@Autowired
	private IRoleDAO dao;
	
	public List<Role> queryAll(){
     
		return dao.queryAll();
	}

}

BookService

package com.lipeiyu.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lipeiyu.dao.IBookDAO;
import com.lipeiyu.pojo.Book;
import com.lipeiyu.util.PageUtil;

@Service
public class BookService {
     
	
	@Autowired
	private IBookDAO dao;
	
	public List<Book> queryAll(PageUtil pageUtil){
     
		Map<String,Integer> map = new HashMap<String,Integer>();
		map.put("startIndex", pageUtil.getStartIndex());
		map.put("pageSize", pageUtil.getPageSize());
		return dao.queryAll(map);
	}
	
	public Book edit(int id) {
     
		return dao.queryByPK(id);
	}
	
	public boolean insert(Book book) {
     
		return dao.add(book) > 0;
	}
	
	public boolean delete(int id) {
     
		return dao.delete(id) > 0;
	}
	
	public boolean update(Book book) {
     
		return dao.update(book) > 0;
	}
	
	public int getCount() {
     
		return dao.getCount();
	}
	
	public List<Book> queryAllb(){
     
		return dao.queryAllb();
	}
}

UserService

package com.lipeiyu.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lipeiyu.dao.IUserDAO;
import com.lipeiyu.pojo.User;
import com.lipeiyu.util.PageUtil;

@Service
public class UserService {
     
	
	@Autowired
	private IUserDAO dao;
	
	public User queryByKeywords(User user){
     
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("user_name", user.getUser_name());
		map.put("password", user.getPassword());
		return dao.queryByKeywords(map);
	}
	
	public boolean add(User user) {
     
		return dao.add(user) > 0;
	}
	
	public boolean delete(int id) {
     
		return dao.delete(id) > 0;
	}
	
	public User edit(int id) {
     
		return dao.queryByPK(id);
	}
	
	public boolean update(User user) {
     
		return dao.update(user) > 0;
	}
	
	public List<User> queryAll(PageUtil pageUtil){
     
		Map<String,Integer> map = new HashMap<String, Integer>();
		map.put("startIndex", pageUtil.getStartIndex());
		map.put("pageSize", pageUtil.getPageSize());
		return dao.queryAll(map);
	}
	
	public int getCount() {
     
		return dao.getCount();
	}
	
	public List<User> queryAllu(){
     
		return dao.queryAllu();
	}
}

BorrowService

package com.lipeiyu.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lipeiyu.dao.IBorrowDAO;
import com.lipeiyu.pojo.Borrow;

@Service
public class BorrowService {
     
	
	@Autowired
	private IBorrowDAO dao;
	
	public List<Borrow> queryAll(){
     
		return dao.queryAll();
	}
	
	public boolean insert(Borrow borrow) {
     
		return dao.add(borrow) > 0;
	}
	
	public boolean delete(int id) {
     
		return dao.delete(id) > 0;
	}
	
	public List<Borrow> queryBykeyWords(Borrow borrow){
     
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("user_id", borrow.getUser_id());
		map.put("book_id", borrow.getBook_id());
		map.put("borrow_date", borrow.getBorrow_date());
		map.put("return_date", borrow.getReturn_date());
		return dao.queryByKeyWords(map);
	}
	
	public Borrow queryByPk(int id) {
     
		return dao.queryByPK(id);
	}
	
	public boolean update(Borrow borrow) {
     
		return dao.update(borrow) > 0;
	}

}

创建Controller层,在里面编写对应的实现方法。通过注解来注入,使其代码更加简单简写,减少了不必要的代码的编写。

BookController

package com.lipeiyu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.lipeiyu.pojo.Book;
import com.lipeiyu.service.BookService;
import com.lipeiyu.util.PageUtil;

@RequestMapping("/book")
@Controller
public class BookController {
     
	
	@Autowired
	private BookService service;
	
	@RequestMapping("/QueryAll.do")
	public String queryAll(Model model,int currentPageIndex) {
     
		PageUtil pageUtil = new PageUtil();
		int totalCount = service.getCount();
		pageUtil.setTotalCount(totalCount);
		pageUtil.setPageSize(5);
		pageUtil.setCurrentPageIndex(currentPageIndex);
		System.out.println(pageUtil.toString());
		List<Book> list = service.queryAll(pageUtil);
		model.addAttribute("list", list);
		model.addAttribute("pageUtil", pageUtil);
		return "library/BookList";
	} 
	
	@RequestMapping("/add.do")
	public String insert(Book book) {
     
		boolean bln = service.insert(book);
		return "library/BookList";
	}
	
	@RequestMapping("/edit.do")
	public String edit(int id,Model model) {
     
		Book book = service.edit(id);
		model.addAttribute("book", book);
		return "library/BookEdit";
	}
	
	@RequestMapping("/update.do")
	public String update(Book book) {
     
		boolean bln = service.update(book);
		return "library/BookList";
	}
	
	@RequestMapping("/delete.do")
	public String delete(int id) {
     
		boolean bln = service.delete(id);
		return "library/BookList";
	}
}

UserController

package com.lipeiyu.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import com.lipeiyu.pojo.Role;
import com.lipeiyu.pojo.User;
import com.lipeiyu.service.RoleService;
import com.lipeiyu.service.UserService;
import com.lipeiyu.util.PageUtil;

@RequestMapping("/user")
@Controller
public class UserController {
     

	@Autowired
	private UserService service;
	@Autowired
	private RoleService rservice;

	@RequestMapping("/Login.do")
	public String login(Model model, User user, HttpServletRequest request, HttpSession session) {
     
		user = service.queryByKeywords(user);
		if (user == null) {
     
			model.addAttribute("error", "账号密码错误");
			return "Login";
		} else {
     
			if (user.getStatus().equals("1") || user.getStatus().equals("-1")) {
     
				model.addAttribute("msg", "账户被停用了,请联系管理员!!");
				return "Login";
			} else {
     
				session = request.getSession();
				session.setAttribute("rele_name", user.getReal_name());
				session.setAttribute("roleid", user.getRole_id());
				return "jsp/Index";
			}
		}
	}

	// 添加
	@RequestMapping("/initAdd.do")
	public String initAdd(User user,Model model) {
     
		List<Role> rList = rservice.queryAll();
		model.addAttribute("rList", rList);
		return "library/UserAdd";
	}

	// 添加
	@RequestMapping("/add.do")
	public String insert(User user) {
     
		boolean bln = service.add(user);
		return "library/UserList";
	}
	
	//查询所有分页
	@RequestMapping("/QueryAll.do")
	public String queryAll(Model model,int currentPageIndex) {
     
		PageUtil pageUtil = new PageUtil();
		int totalCount = service.getCount();
		pageUtil.setTotalCount(totalCount);
		pageUtil.setPageSize(5);
		pageUtil.setCurrentPageIndex(currentPageIndex);
		System.out.println(pageUtil.toString());
		List<User> list = service.queryAll(pageUtil);
		model.addAttribute("list", list);
		model.addAttribute("pageUtil", pageUtil);
		return "library/UserList";
	} 
	
	@RequestMapping("/edit.do")
	public String edit(int id,Model model) {
     
		List<Role> rList = rservice.queryAll();
		User user = service.edit(id);
		model.addAttribute("rList", rList);
		model.addAttribute("user", user);
		return "library/UserEdit";
	}
	
	@RequestMapping("/delete.do")
	public String delete(int id) {
     
		boolean bln = service.delete(id);
		return "library/UserList";
	}
	
	@RequestMapping("/update.do")
	public String update(User user) {
     
		boolean bln = service.update(user);
		return "library/UserList";
	}

}

BorrowController

package com.lipeiyu.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lipeiyu.pojo.Book;
import com.lipeiyu.pojo.Borrow;
import com.lipeiyu.pojo.User;
import com.lipeiyu.service.BookService;
import com.lipeiyu.service.BorrowService;
import com.lipeiyu.service.UserService;

@RequestMapping("/borrow")
@Controller
public class BorrowController {
     
	
	@Autowired
	private BorrowService service;
	@Autowired
	private UserService uservice;
	@Autowired
	private BookService bservice;
	
	@RequestMapping("/QueryAll")
	public String queryAll(Model model) {
     
		List<Borrow> list = service.queryAll();
		List<User> uList = uservice.queryAllu();
		List<Book> bList = bservice.queryAllb();
		model.addAttribute("uList", uList);
		model.addAttribute("bList", bList);
		model.addAttribute("list", list);
		return "library/BorrowList";
	}
	
	@RequestMapping("/add.do")
	public String add(Borrow borrow) {
     
		boolean bln = service.insert(borrow);
		return "library/BorrowList";
	}
	
	@RequestMapping("/delete")
	public String delete(int id) {
     
		boolean bln = service.delete(id);
		return "library/BorrowList";
	}
	
	@RequestMapping("/initAdd.do")
	public String initAdd(Model model) {
     
		List<User> uList = uservice.queryAllu();
		List<Book> bList = bservice.queryAllb();
		model.addAttribute("uList", uList);
		model.addAttribute("bList", bList);
		return "library/BorrowAdd";
	}
	
	@RequestMapping("/queryBykeywords.do")
	public String queryByKeywords(Borrow borrow,Model model) {
     
		List<Borrow> list = service.queryBykeyWords(borrow);
		List<User> uList = uservice.queryAllu();
		List<Book> bList = bservice.queryAllb();
		model.addAttribute("uList", uList);
		model.addAttribute("bList", bList);
		model.addAttribute("list", list);
		return "library/BorrowList";
	}
	
	@RequestMapping("/edit.do")
	public String edit(int id,Model model) {
     
		Borrow borrow = service.queryByPk(id);
		List<User> uList = uservice.queryAllu();
		List<Book> bList = bservice.queryAllb();
		model.addAttribute("uList", uList);
		model.addAttribute("bList", bList);
		model.addAttribute("borrow", borrow);
		return "library/BorrowEdit";
	}
	
	@RequestMapping("/update.do")
	public String update(Borrow borrow) {
     
		boolean bln = service.update(borrow);
		return "library/BorrowList";
	}
}

相关的jsp界面内容如下

UserList.jsp 用户信息功能界面

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!-- //判断值是否为空,跳转到Servlet中取值 -->
<c:if test="${list == null}">
	<!-- 跳转到Servlet -->
	<c:redirect url="/user/QueryAll.do?currentPageIndex=0"></c:redirect>
	<!-- * 代表任意字符 -->
</c:if>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Login.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DouPHP 管理中心 - 商品分类</title>
<meta name="Copyright" content="Douco Design." />
<link href="css/public.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/check.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jquery-1.6.4.js"></script>
<script type="text/javascript">
	function page_onchange(obj){
     
		var value = obj.value;
		//alert(value);
		//跳转
		window.location.href
		="/BookLibrary/user/QueryAll.do?currentPageIndex="+value;
	}
	//是否删除的提示
	function delete_onclick(){
     
		var bln = confirm("是否删除该笔资料?");
		//直接返回
		return bln;
	}
	/* 上一页和下一页禁用操作 */
	$(function(){
     
		//首先获取当前页及尾页页码
		var pageIndex = "${pageUtil.currentPageIndex+1}";
		var totalPage = "${pageUtil.totalPageCount}";
		if(pageIndex == 1){
     //当前页为首页
			$("#pPage").css("pointer-events","none");
		}
		if(pageIndex == totalPage){
     //当前页为尾页
			$("#nPage").css("pointer-events","none");
		}
	})
</script>

</head>
<body>
	<div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>用户管理</strong>
		</div>
		<div class="mainBox"
			style="height: auto !important; height: 550px; min-height: 550px; margin-top: 100px; ">
			<!-- onsubmit提交按钮触发事件  check是要做什么事情和方法-->
			<a href="/BookLibrary/user/initAdd.do" class="actionBtn">添加</a>
			<hr />
			<div id="tableBasic_aboveLine">用户列表</div>
			<table width="100%" border="0" cellpadding="8" cellspacing="0"
				class="tableBasic">
				<tr>
					<th>用户编号</th>
					<th>用户名称</th>
					<th>密码</th>
					<th>身份证号</th>
					<th>用户姓名</th>
					<th>用户状态</th>
					<th>角色</th>
					<th>操作</th>
				</tr>
				<!--  循环遍历-->
				<c:forEach items="${list}" var="entity">
					<tr>
						<td>${
     entity.id}</td>
						<td>${
     entity.user_name}</td>
						<td>${
     entity.password}</td>
						<td>${
     entity.id_no}</td>
						<td>${
     entity.real_name}</td>
						<td><c:if test="${entity.status==1}">挂失
						</c:if> <c:if test="${entity.status==0}">正常
						</c:if> <c:if test="${entity.status==-1}">锁定
						</c:if></td>
						<td>${
     entity.role.role_name}
						</td>
						<td>
							<!-- onclick 点击事件  需要返回值判断是否继续执行--> 
							<a href="/BookLibrary/user/edit.do?id=${entity.id}">修改</a>| 
							<a onclick="return delete_onclick()"
							href="/BookLibrary/user/delete.do?id=${entity.id}">删除</a>
					</tr>
				</c:forEach>
			</table>
			<div id="divPageBreaker">
				总共<span id="totalCount" style="color: red">${
     pageUtil.totalCount}</span>条数据,
				每页<span id="pageSize" style="color: red">${
     pageUtil.pageSize}</span>条数据,
				共<span id="pageCount" style="color: red">${
     pageUtil.totalPageCount}</span>页,
				当前是第<span id="currentPageIndex" style="color: red">${
     pageUtil.currentPageIndex+1}</span>&nbsp;
				<a 
					href="/KQSSSM/Employee/QueryAll.do?currentPageIndex=${pageUtil.currentPageIndex-1 }" id="pPage">上一页</a>&nbsp;
				
				<a 
					href="/KQSSSM/Employee/QueryAll.do?currentPageIndex=${pageUtil.currentPageIndex+1 }" id="nPage">下一页</a>&nbsp;
				<!-- onchange 事件对象 -->
				 <select id="page" name="page" onchange="page_onchange(this)"><!-- this代表当前整个事件对象 ,事件源,就是当前整个element对象-->
					<c:forEach begin="0" end="${pageUtil.totalPageCount-1}" var="i">
					<!--什么时候被选中?只有i==当前页才被选中  -->
						<c:choose>
							<c:when test="${i == pageUtil.currentPageIndex}">
								<option value="${i}" selected="selected">${
     i+1}</option>
							</c:when>
							<c:otherwise>
								<option value="${i}">${
     i+1}</option>
							</c:otherwise>
						</c:choose>
						
					</c:forEach>
				</select> 
			</div>
		</div>
	</div>
</body>
</html>

UserEdit.jsp 用户信息修改界面

<%@ page language="java" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">    
    <title>My JSP 'EmployeeEdit.jsp' starting page</title>    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="css/public.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
  </head>
  
  <body>
    <div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>用户管理</strong><b>></b><strong>用户信息修改</strong>
		</div>
		<div class="mainBox"
			style="height:auto!important;height:550px;min-height:550px;">
			<form action="/BookLibrary/user/update.do" method="post">
			<table width="100%" border="0" cellpadding="8" cellspacing="0"
				class="tableBasic">
				<tr>
					<td><font style="color:red">*&nbsp;</font>用户名</td>
					<td>
					<input type="hidden" id="id" name="id" value="${user.id}" />
					<input type="text" name="user_name" value="${user.user_name}"/></td>
				</tr>
				<tr>
						<td align="left"><font color="red">*&nbsp;</font>密码</td>
						<td><input type="password" id="password" name="password"  value="${user.password}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>身份证号</td>
						<td><input type="text" id="id_no" name="id_no" value="${user.id_no}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>用户姓名</td>
						<td><input type="text" id="real_name" name="real_name" value="${user.real_name}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>用户状态</td>
						<td>
						<c:choose>
							<c:when test="${user.status==1}">
							<input class="cls_rad" type="radio" name="status"
							value="1" checked="checked" />挂失 &nbsp; <input class="cls_rad" type="radio"
							name="status" value="0" checked="checked" />正常 <input
							class="cls_rad" type="radio" name="status" value="-1" />锁定
							</c:when>
							<c:when test="${user.status==0}">
							<input class="cls_rad" type="radio" name="status"
							value="1"  />挂失 &nbsp; <input class="cls_rad" type="radio"
							name="status" value="0" checked="checked" />正常 <input
							class="cls_rad" type="radio" name="status" value="-1" />锁定
							</c:when>
							<c:when test="${user.status==-1}">
							<input class="cls_rad" type="radio" name="status"
							value="1" checked="checked" />挂失 &nbsp; <input class="cls_rad" type="radio"
							name="status" value="0" checked="checked" />正常 <input
							class="cls_rad" type="radio" name="status" value="-1" checked="checked"/>锁定
							</c:when>
							<c:otherwise>
								<input class="cls_rad" type="radio" name="status"
							value="1" />挂失 &nbsp; <input class="cls_rad" type="radio"
							name="status" value="0" />正常 <input
							class="cls_rad" type="radio" name="status" value="-1" />锁定
							</c:otherwise>
						</c:choose></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>角色</td>
						<td><select name="role_id">
								<option value=0>全部</option>
								<c:forEach items="${rList}" var="role">
									<c:choose>
										<c:when test="${user.role_id==role.id}">
											<option value="${role.id}" selected="selected">${
     role.role_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${role.id}">${
     role.role_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
				<tr>
					<td colspan="2" align="center"><input class="actionBtn"
						type="Submit" value="修改">
					</td>
				</tr>
			</table>
			
		 </form>
		</div>
	</div>
  </body>
</html>

UserAdd.jsp 用户信息添加界面

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'EmployeeAdd.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="css/public.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
<script type="text/javascript">
	//进行验证
	function check() {
     
		//得到部门控件(元素),通过元素的id得到元素控件
		var employeeName = document.getElementById("employeeName");
		//判断值是否为空
		if (employeeName.value == "") {
     
			//为空为假
			alert("员工姓名不能为空");
			return false;//如果返回true:继续提交表单   false:不在提交表单
		}
		return true;//验证通过
	}
</script>
</head>

<body>
	<div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>用户管理</strong><b>></b><strong>用户添加</strong>
		</div>
		<div class="mainBox"
			style="height: auto !important; height: 550px; min-height: 550px;">
			<form onsubmit="return check()" action="/BookLibrary/user/add.do"
				method="post">
				<table width="100%" border="0" cellpadding="8" cellspacing="0"
					class="tableBasic">
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>账号</td>
						<td><input type="text" id="user_name" name="user_name" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>密码</td>
						<td><input type="password" id="password" name="password" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>身份证号</td>
						<td><input type="text" id="id_no" name="id_no" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>用户真实姓名</td>
						<td><input type="text" id="real_name" name="real_name" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>用户状态</td>
						<td><input class="cls_rad" type="radio" name="status"
							value="1" />挂失 &nbsp; <input class="cls_rad" type="radio"
							name="status" value="0" checked="checked" />正常 <input
							class="cls_rad" type="radio" name="status" value="-1" />锁定</td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>角色</td>
						<td><select name="role_id" id="role_id">
								<option value=0>全部</option>
								<c:forEach items="${rList}" var="role">
									<c:choose>
										<c:when test="${param.role_id==role.id}">
											<option value="${role.id}" selected="selected">${
     role.role_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${role.id}">${
     role.role_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input class="actionBtn"
							type="submit" value="添加用户" name="btnAdd" id="btnAdd" /></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>

BorrowList.jsp借阅信息功能界面

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!-- //判断值是否为空,跳转到Servlet中取值 -->
<c:if test="${list == null}">
	<!-- 跳转到Servlet -->
	<c:redirect url="/borrow/QueryAll.do"></c:redirect><!-- * 代表任意字符 -->
</c:if>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Login.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DouPHP 管理中心 - 商品分类</title>
<meta name="Copyright" content="Douco Design." />
<link href="css/public.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/check.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jquery-1.6.4.js"></script>
<script type="text/javascript">
	
	//是否删除的提示
	function delete_onclick(){
     
		var bln = confirm("是否删除该笔资料?");
		//直接返回
		return bln;
	}
	
</script>

</head>
<body>
	<div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>借阅管理</strong>
		</div>
		<div class="mainBox"
			style="height: auto !important; height: 550px; min-height: 550px;">
			<!-- onsubmit提交按钮触发事件  check是要做什么事情和方法-->
			<form id="form1" name="form1" method="post" onsubmit="return check()"
				 action="/BookLibrary/borrow/queryBykeywords.do">
				<table width="100%" border="0" cellpadding="8" cellspacing="0"
					class="tableBasic">
					<tr>
						<td>用户:</td>
						<td><select name="user_id" id="user_id">
								<option value="0">所有用户</option>
								<c:forEach items="${uList}" var="user">
									<c:choose>
										<c:when test="${param.user_id==user.id}">
											<option value="${user.id}" selected="selected">${
     user.user_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${user.id}">${
     user.user_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td>书籍:</td>
						<td><select name="book_id" id="book_id">
								<option value="0">所有图书</option>
								<c:forEach items="${bList}" var="book">
									<c:choose>
										<c:when test="${param.book_id==book.id}">
											<option value="${book.id}" selected="selected">${
     book.book_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${book.id}">${
     book.book_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td>图书借出日期:</td>
						<td><input type="text" name="borrow_date" value="${param.borrow_date}"/></td>
					</tr>
					<tr>
						<td>图书归还日期:</td>
						<td><input type="text" name="return_date" value="${param.return_date}"/></td>
					</tr>
					<tr>
						<td align="center" colspan="2"><input class="actionBtn"
							type="submit" value="查询" /></td>
					</tr>
				</table>
			</form>
			<hr />
			<div style="padding-left: 1000px;">
				<a href="/BookLibrary/borrow/initAdd.do" class="actionBtn" style="padding-right: 20px;">添加</a>
			</div>
			
			<hr />
			<div id="tableBasic_aboveLine">借阅信息列表</div>
			<table width="100%" border="0" cellpadding="8" cellspacing="0"
				class="tableBasic">
				<tr>
					<th>借阅编号</th>
					<th>用户名</th>
					<th>身份证号</th>
					<th>书名</th>
					<th>出版社</th>
					<th>图书作者</th>
					<th>出版日期</th>
					<th>借阅数量</th>
					<th>借出日期</th>
					<th>归还日期</th>
					<th>操作</th>
				</tr>
				<!--  循环遍历-->
				<c:forEach items="${list}" var="entity">
					<tr>
						<td>${
     entity.id}</td>
						<td>${
     entity.user.user_name}</td>
						<td>${
     entity.user.id_no}</td>
						<td>${
     entity.book.book_name}</td>
						<td>${
     entity.book.press_name}</td>
						<td>${
     entity.book.author_name}</td>
						<td>${
     entity.book.pub_date}</td>
						<td>${
     entity.borrow_count}</td>
						<td>${
     entity.borrow_date}</td>
						<td><c:choose>
							<c:when test="${entity.return_date==null}">
								未归还
							</c:when>
							<c:otherwise>
								${
     entity.return_date}
							</c:otherwise>
						</c:choose>
						</td>
						<td>
						<!-- onclick 点击事件  需要返回值判断是否继续执行-->
						<a href="/BookLibrary/borrow/edit.do?id=${entity.id}">修改</a>| 
							<a onclick="return delete_onclick()"
							href="/BookLibrary/borrow/delete.do?id=${entity.id}">删除</a>
					</tr>
				</c:forEach>
			</table>
		</div>
	</div>
</body>
</html>

BorrowEdit.jsp 借阅信息修改界面

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'EmployeeAdd.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="css/public.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
</head>

<body>
	<div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>借阅管理</strong><b>></b><strong>借阅信息修改</strong>
		</div>
		<div class="mainBox"
			style="height: auto !important; height: 550px; min-height: 550px;">
			<form onsubmit="return check()" action="/BookLibrary/borrow/update.do"
				method="post">
				<table width="100%" border="0" cellpadding="8" cellspacing="0"
					class="tableBasic">
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借阅用户
						<input type="hidden" id="id" name="id" value="${borrow.id}" /></td>
						<td><select name="user_id" id="user_id" disabled="disabled" >
								<option value=0>全部</option>
								<c:forEach items="${uList}" var="user">
									<c:choose>
										<c:when test="${borrow.user_id==user.id}">
											<option value="${user.id}" selected="selected">${
     user.user_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${user.id}">${
     user.user_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借阅图书</td>
						<td><select name="book_id" id="book_id" disabled="disabled" >
								<option value=0>全部</option>
								<c:forEach items="${bList}" var="book">
									<c:choose>
										<c:when test="${borrow.book_id==book.id}">
											<option value="${book.id}" selected="selected">${
     book.book_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${book.id}">${
     book.book_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借阅数量</td>
						<td><input type="text" id="borrow_count" name="borrow_count" readonly="readonly" value="${borrow.borrow_count}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借出日期</td>
						<td><input type="text" id="borrow_date" name="borrow_date" readonly="readonly" value="${borrow.borrow_date}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>归还日期</td>
						<td><input type="text" id="return_date" name="return_date" value="${borrow.return_date}"/></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input class="actionBtn"
							type="submit" value="添加借阅信息" name="btnAdd" id="btnAdd" /></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>

BorrowAdd.jsp 借阅信息添加界面

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'EmployeeAdd.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link href="css/public.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
</head>

<body>
	<div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>借阅管理</strong><b>></b><strong>借阅信息添加</strong>
		</div>
		<div class="mainBox"
			style="height: auto !important; height: 550px; min-height: 550px;">
			<form onsubmit="return check()" action="/BookLibrary/borrow/add.do"
				method="post">
				<table width="100%" border="0" cellpadding="8" cellspacing="0"
					class="tableBasic">
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借阅用户</td>
						<td><select name="user_id" id="user_id">
								<option value=0>全部</option>
								<c:forEach items="${uList}" var="user">
									<c:choose>
										<c:when test="${param.user_id==user.id}">
											<option value="${user.id}" selected="selected">${
     user.user_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${user.id}">${
     user.user_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借阅图书</td>
						<td><select name="book_id" id="book_id">
								<option value=0>全部</option>
								<c:forEach items="${bList}" var="book">
									<c:choose>
										<c:when test="${param.book_id==book.id}">
											<option value="${book.id}" selected="selected">${
     book.book_name}</option>
										</c:when>
										<c:otherwise>
											<option value="${book.id}">${
     book.book_name}</option>
										</c:otherwise>
									</c:choose>
								</c:forEach>
						</select></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借阅数量</td>
						<td><input type="text" id="borrow_count" name="borrow_count" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>借出日期</td>
						<td><input type="text" id="borrow_date" name="borrow_date" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>归还日期</td>
						<td><input type="text" id="return_date" name="return_date" /></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input class="actionBtn"
							type="submit" value="添加借阅信息" name="btnAdd" id="btnAdd" /></td>
					</tr>
				</table>
			</form>
		</div>
	</div>
</body>
</html>

BookList.jsp 图书信息功能界面

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!-- //判断值是否为空,跳转到Servlet中取值 -->
<c:if test="${list == null}">
	<!-- 跳转到Servlet -->
	<c:redirect url="/book/QueryAll.do?currentPageIndex=0"></c:redirect><!-- * 代表任意字符 -->
</c:if>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>My JSP 'Login.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>DouPHP 管理中心 - 商品分类</title>
<meta name="Copyright" content="Douco Design." />
<link href="css/public.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/check.js"></script>
<script type="text/javascript" src="<%=basePath%>/js/jquery-1.6.4.js"></script>
<script type="text/javascript">
	function page_onchange(obj){
     
		var value = obj.value;
		//alert(value);
		//跳转
		window.location.href
		="/BookLibrary/book/QueryAll.do?currentPageIndex="+value;
	}
	//是否删除的提示
	function delete_onclick(){
     
		var bln = confirm("是否删除该笔资料?");
		//直接返回
		return bln;
	}
	/* 上一页和下一页禁用操作 */
	$(function(){
     
		//首先获取当前页及尾页页码
		var pageIndex = "${pageUtil.currentPageIndex+1}";
		var totalPage = "${pageUtil.totalPageCount}";
		if(pageIndex == 1){
     //当前页为首页
			$("#pPage").css("pointer-events","none");
		}
		if(pageIndex == totalPage){
     //当前页为尾页
			$("#nPage").css("pointer-events","none");
		}
	})
</script>

</head>
<body>
	<div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>图书管理</strong>
		</div>
		<div class="mainBox"
			style="height: auto !important; height: 550px; min-height: 550px;">
			<!-- onsubmit提交按钮触发事件  check是要做什么事情和方法-->
			<form id="form1" name="form1" method="post" onsubmit="return check()"
				 action="/BookLibrary/book/add.do">
				<table width="100%" border="0" cellpadding="8" cellspacing="0"
					class="tableBasic">
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>图书名称</td>
						<td><input type="text" id="book_name"
							name="book_name" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>出版社名称</td>
						<td><input type="text" id="press_name" name="press_name" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>作者名</td>
						<td><input type="text" id="author_name" name="author_name" /></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>出版日期</td>
						<td><input type="text" id="pub_date" name="pub_date" /></td>
					</tr>
					<tr>
						<td colspan="2" align="center"><input class="actionBtn"
							type="submit" value="添加图书" name="btnAdd" id="btnAdd" /></td>
					</tr>
				</table>
			</form>
			<hr />

			<div id="tableBasic_aboveLine">图书列表</div>
			<table width="100%" border="0" cellpadding="8" cellspacing="0"
				class="tableBasic">
				<tr>
					<th>图书编号</th>
					<th>图书名称</th>
					<th>出版社名称</th>
					<th>作者名</th>
					<th>出版日期</th>
					<th>操作</th>
				</tr>
				<!--  循环遍历-->
				<c:forEach items="${list}" var="entity">
					<tr>
						<td>${
     entity.id}</td>
						<td>${
     entity.book_name}</td>
						<td>${
     entity.press_name}</td>
						<td>${
     entity.author_name}</td>
						<td>${
     entity.pub_date}</td>
						<td>
						<!-- onclick 点击事件  需要返回值判断是否继续执行-->
						<a href="/BookLibrary/book/edit.do?id=${entity.id}">修改</a>| 
							<a onclick="return delete_onclick()"
							href="/BookLibrary/book/delete.do?id=${entity.id}">删除</a>
					</tr>
				</c:forEach>
			</table>
			<div id="divPageBreaker">
				总共<span id="totalCount" style="color: red">${
     pageUtil.totalCount}</span>条数据,
				每页<span id="pageSize" style="color: red">${
     pageUtil.pageSize}</span>条数据,
				共<span id="pageCount" style="color: red">${
     pageUtil.totalPageCount}</span>页,
				当前是第<span id="currentPageIndex" style="color: red">${
     pageUtil.currentPageIndex+1}</span>&nbsp;
				<a 
					href="/KQSSSM/Employee/QueryAll.do?currentPageIndex=${pageUtil.currentPageIndex-1 }" id="pPage">上一页</a>&nbsp;
				
				<a 
					href="/KQSSSM/Employee/QueryAll.do?currentPageIndex=${pageUtil.currentPageIndex+1 }" id="nPage">下一页</a>&nbsp;
				<!-- onchange 事件对象 -->
				 <select id="page" name="page" onchange="page_onchange(this)"><!-- this代表当前整个事件对象 ,事件源,就是当前整个element对象-->
					<c:forEach begin="0" end="${pageUtil.totalPageCount-1}" var="i">
					<!--什么时候被选中?只有i==当前页才被选中  -->
						<c:choose>
							<c:when test="${i == pageUtil.currentPageIndex}">
								<option value="${i}" selected="selected">${
     i+1}</option>
							</c:when>
							<c:otherwise>
								<option value="${i}">${
     i+1}</option>
							</c:otherwise>
						</c:choose>
						
					</c:forEach>
				</select> 
			</div>
			
		</div>
	</div>
</body>
</html>

BookEdit.jsp 图书信息修改界面

<%@ page language="java" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">    
    <title>My JSP 'EmployeeEdit.jsp' starting page</title>    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<link href="css/public.css" rel="stylesheet" type="text/css">
	<script type="text/javascript" src="<%=basePath%>/js/jquery.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>/js/global.js"></script>
  </head>
  
  <body>
    <div id="dcMain1">
		<div id="urHere">
			图书管理系统<b>></b><strong>基本设置</strong><b>></b><strong>图书管理</strong><b>></b><strong>图书信息修改</strong>
		</div>
		<div class="mainBox"
			style="height:auto!important;height:550px;min-height:550px;">
			<form action="/BookLibrary/book/update.do" method="post">
			<table width="100%" border="0" cellpadding="8" cellspacing="0"
				class="tableBasic">
				<tr>
					<td><font style="color:red">*&nbsp;</font>图书名称</td>
					<td>
					<input type="hidden" id="id" name="id" value="${book.id}" />
					<input type="text" name="book_name" value="${book.book_name}"/></td>
				</tr>
				<tr>
						<td align="left"><font color="red">*&nbsp;</font>出版社名称</td>
						<td><input type="text" id="press_name" name="press_name"  value="${book.press_name}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>作者名</td>
						<td><input type="text" id="author_name" name="author_name" value="${book.author_name}"/></td>
					</tr>
					<tr>
						<td align="left"><font color="red">*&nbsp;</font>出版日期</td>
						<td><input type="text" id="pub_date" name="pub_date" value="${book.pub_date}"/></td>
					</tr>
				<tr>
					<td colspan="2" align="center"><input class="actionBtn"
						type="Submit" value="修改图书信息">
					</td>
				</tr>
			</table>
			
		 </form>
		</div>
	</div>
  </body>
</html>

Login.jsp 登录界面

<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>"> 
    <title>My JSP 'Login.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<style type="text/css">
	body
	{
     
		background: url("images/Login.jpg") center center no-repeat;
		text-align:center;
	}
	#t_login
	{
     
		width:500px;
		height:300px;
		position:relative;
		left:450px;
		top:100px;
		padding-top:20px;
		background:rgba(0,0,255,0.1);
		display:center;
		border-radius:20px;
		box-shadow:5px 5px 25px green;
	}
	table{
     
		float:center;
	}
	#btnLogin,#btnReset
	{
     
		border-radius:10px;
		background:red;
		width:100px;
		height:30px;
		
	}
</style>
  </head>
  
  <body>
    <form action="/BookLibrary/user/Login.do"  method="post">
       <div id="t_login">
       <h1 align="center">图书管理系统</h1>
       <table  align="center" width="300px" height="200px">
       		<tr>
       			<td>用户名:</td>
       			<td><input type="text" name="user_name" id="user_name"  /></td>
       		</tr>
       		<tr>
       			<td>密码:</td>
       			<td><input type="password" name="password"  id="password"  /></td>
       		</tr>
       		<tr>
       			<td colspan="2">
       				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       				<input type="submit" id="btnLogin" name="btnLogin" value="登录"/>
       				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="reset"  id="btnReset" name="btnReset" value="重置"/>
       				<!-- id用在客户端的 name用在服务器端 -->
       			</td>
       		</tr>
       		<tr>
       			<td colspan="2">
       				<font style="font-size: 15px;text-align: center;padding-right: 10%" color="red"><strong>${
     error}</strong></font>
       				<font style="font-size: 15px;text-align: center;padding-right: 10%" color="red"><strong>${
     msg}</strong></font>
       			</td>
       		</tr>
       </table>
    	</div>
    </form>
  </body>
</html>

这个图书管理系统项目是一个课余考试项目,虽然功能简单,但是我还是在原有的基础上添加了分页功能和模糊查询等功能,总体上说这个项目并不完善很简陋。第一次写框架技术项目的博客可能缺点也有很多,讲解不太好,或者代码的编写不是很简洁简练。希望大家多多包涵。

你可能感兴趣的:(SSM框架技术,java,spring,mybatis,springmvc,mysql)