国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

圖書管理系統(tǒng)的搭建

這篇具有很好參考價值的文章主要介紹了圖書管理系統(tǒng)的搭建。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

1.圖書管理系統(tǒng)的搭建

流程圖

圖書管理系統(tǒng)的搭建
頁面跳轉(zhuǎn):
圖書管理系統(tǒng)的搭建

代碼整體布局:

圖書管理系統(tǒng)的搭建

導入框架和包:

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

實現(xiàn)效果:

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

圖書管理系統(tǒng)的搭建

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
在innodb存儲引擎下,會到自增斷層,如下(pid=4):
圖書管理系統(tǒng)的搭建
不適用拼接,正常插入:
圖書管理系統(tǒng)的搭建

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

代碼部分:

創(chuàng)建數(shù)據(jù)庫:

#創(chuàng)建數(shù)據(jù)庫
create database 70730_db
default character set utf8mb4 #設置字符集
default collate utf8mb4_general_ci #設置排序規(guī)則 

創(chuàng)建表:

create table books
(
	bookId int primary key auto_increment,
	bookName varchar(200),
	author varchar(20),
	price decimal(5,1),
	pubDate date
);

select * from books;

-- insert into books  
-- (bookName,author,price,pubDate)
-- select '圖書1','作者1',2.5,'2000-01-01' union  #在innodb存儲引擎下,會到自增斷層
-- select '圖書2','作者2',3.5,'2000-01-01';


insert into books
(bookName,author,price,pubDate)
values
('圖書1','作者1',1.1,'2001-01-01'),
('圖書2','作者2',2.2,'2002-02-02');

BaseDAO:

package com.util;

import java.sql.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class BaseDAO {

	//四大金剛
	//驅(qū)動類
	private static final String DRIVER="com.mysql.cj.jdbc.Driver";
	//連接地址
	private static final String URL="jdbc:mysql://localhost:3306/70730_db?useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai";
	//用戶名
	private static final String USER="root";
	//密碼
	private static final String PASSWORD="123456";

	//獲取連接
	public static Connection getConnection(){

		Connection con = null;

		try{
			//加載驅(qū)動類
			Class.forName(DRIVER);
			//獲取連接
			con = DriverManager.getConnection(URL,USER,PASSWORD);
			
		}catch(Exception ex){
			ex.printStackTrace();
		}

		return con;
	}

	//關(guān)閉數(shù)據(jù)庫對象
	public static void closeAll(Connection con,Statement st,ResultSet rs){
		
		if(rs!=null){
			try{
				rs.close();
			}catch(Exception ex){
				ex.printStackTrace();
			}
			
		}

		if(st!=null){

			try{
				st.close();
			}catch(Exception ex){
				ex.printStackTrace();
			}
			
		}

		if(con!=null){
			try{
				con.close();
			}catch(Exception ex){
				ex.printStackTrace();
			}
			
		}

	}


	//通用設置參數(shù)方法
	public static void setParams(PreparedStatement pst,Object[] params){

		if(params==null){
			return;
		}

		for(int i=0;i<params.length;i++){
			try{
				pst.setObject(i+1,params[i]);
			}catch(Exception ex){
				ex.printStackTrace();
			}
		}
	}


	//通用增刪改
	public static int executeUpdate(String sql,Object[] params){

		Connection con = null;
		PreparedStatement pst = null;
		
		int res = -1;
		
		try{

			//獲取連接
			con = getConnection();
			//創(chuàng)建預編譯命令執(zhí)行對象
			pst = con.prepareStatement(sql);
			//設置參數(shù)
			setParams(pst,params);
			//執(zhí)行
			res = pst.executeUpdate();

		}catch(Exception ex){
			ex.printStackTrace();
		}finally{
			closeAll(con,pst,null);
		}
		
		return res;
	}


	//通用查詢
	public static List<Map<String,Object>> executeQuery(String sql,Object[] params) {

		List<Map<String,Object>> rows = new ArrayList<>();

		Connection con = null;
		PreparedStatement pst = null;
		ResultSet rs = null;

		try{
			//獲取連接	
			con = getConnection();			
			//獲取命令對象
			pst = con.prepareStatement(sql);
			//設置參數(shù)
			setParams(pst,params);
			//執(zhí)行查詢
			rs = pst.executeQuery();

			//通過rs獲取結(jié)果集的結(jié)構(gòu)信息
			ResultSetMetaData rsmd =  rs.getMetaData();
			//獲取結(jié)果集的列數(shù)
			int colCount = rsmd.getColumnCount();

			//遍歷查詢結(jié)果,并封裝到List<Map>中
			while(rs.next()){
				//用Map存儲當前行的各個列數(shù)據(jù)
				Map<String,Object> map = new HashMap<>();
				//循環(huán)獲取每一列的信息
				for(int i=1;i<=colCount;i++){
					//獲取列名(使用rsmd)
					String colName = rsmd.getColumnLabel(i);
					//獲取列值(使用rs)
					Object colVal = rs.getObject(i);
					//將當前列存儲到map中
					map.put(colName,colVal);								
				}
				
				//將遍歷的當前行的數(shù)據(jù)存儲到List中
				rows.add(map);
							
			}


		}catch(Exception ex){
			ex.printStackTrace();
		}finally{
			closeAll(con,pst,rs);
		}
		
		return rows;

	}

}

Books:

package com.entity;

import java.util.Date;

public class Books {
    private Integer bookId;
    private String bookName;
    private String author;
    private Double price;
    private Date pubDate;

    public Books() {
    }

    public Books(Integer bookId, String bookName, String author, Double price, Date pubDate) {
        this.bookId = bookId;
        this.bookName = bookName;
        this.author = author;
        this.price = price;
        this.pubDate = pubDate;
    }

    public Books(String bookName, String author, Double price, Date pubDate) {
        this.bookName = bookName;
        this.author = author;
        this.price = price;
        this.pubDate = pubDate;
    }

    public Integer getBookId() {
        return bookId;
    }

    public void setBookId(Integer bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public Date getPubDate() {
        return pubDate;
    }

    public void setPubDate(Date pubDate) {
        this.pubDate = pubDate;
    }

    @Override
    public String toString() {
        return "Books{" +
                "bookId=" + bookId +
                ", bookName='" + bookName + '\'' +
                ", author='" + author + '\'' +
                ", price=" + price +
                ", pubDate=" + pubDate +
                '}';
    }
}

IBooksDAO:

package com.dao;

import com.entity.Books;

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

public interface IBooksDAO {
    //查詢所有
    List<Map<String, Object>> listAll();
    //插入
    int insert(Books books);
    //修改
    int update(Books books);
    //刪除
    int delete(Integer bookId);
}

BooksDAOImpl:

package com.dao.impl;

import com.dao.IBooksDAO;
import com.entity.Books;
import com.util.BaseDAO;

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

public class BooksDAOImpl implements IBooksDAO {
    @Override
    public List<Map<String, Object>> listAll() {
        String sql="select bookId,bookName,author,price,pubDate from books";
        return BaseDAO.executeQuery(sql,null);
    }

    @Override
    public int insert(Books books) {
        String sql="insert into books"+
                "    (bookName,author,price,pubDate)"+
                "values"+
                " (?,?,?,?)";
        Object[] params={
                books.getBookName(),
                books.getAuthor(),
                books.getPrice(),
                books.getPubDate()
        };
        return BaseDAO.executeUpdate(sql,params);
    }

    @Override
    public int update(Books books) {
        String sql="update books"+
                "   set bookName=?,author=?,price=?,pubDate=? "+
                "   where bookId=?";
        Object[] params={
                books.getBookName(),
                books.getAuthor(),
                books.getPrice(),
                books.getPubDate(),
                books.getBookId()
        };
        return BaseDAO.executeUpdate(sql,params);
    }

    @Override
    public int delete(Integer bookId) {
        String sql="delete from books"+
                "   where bookId=?";
        Object[] params={
                bookId
        };
        return BaseDAO.executeUpdate(sql,params);
    }
}

IBooksService:

package com.service;

import com.entity.Books;

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

public interface IBooksService {
    List<Map<String, Object>> listAll();
    //插入
    int insert(Books books);
    //修改
    int update(Books books);
    //刪除
    int delete(Integer bookId);
}

BooksServiceImpl:

package com.service.impl;

import com.dao.IBooksDAO;
import com.dao.impl.BooksDAOImpl;
import com.entity.Books;
import com.service.IBooksService;

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

public class BooksServiceImpl implements IBooksService {
    IBooksDAO booksDAO=new BooksDAOImpl();
    @Override
    public List<Map<String, Object>> listAll() {
        return booksDAO.listAll();
    }

    @Override
    public int insert(Books books) {
        return booksDAO.insert(books);
    }

    @Override
    public int update(Books books) {
        return booksDAO.update(books);
    }

    @Override
    public int delete(Integer bookId) {
        return booksDAO.delete(bookId);
    }
}

package com.servlet;

import com.entity.Books;
import com.service.IBooksService;
import com.service.impl.BooksServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

@WebServlet(urlPatterns = "/BooksServlet/*")
public class BooksServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uri=req.getRequestURI();
        System.out.println("uri: "+uri);
        String url=req.getRequestURL().toString();
        System.out.println("url: "+url);

        String process=uri.substring(uri.lastIndexOf("/")+1);
        System.out.println("截取后: "+process);

        String gp=req.getContextPath();
        System.out.println("gp: "+gp);

        //設置請求數(shù)據(jù)的編碼,避免獲取數(shù)據(jù)亂碼
        req.setCharacterEncoding("utf-8");

        switch (process){
            case "query":
                this.query(req,resp);
                break;
            case "toAdd":
                this.toAdd(req,resp);
                break;
            case "add":
                this.add(req,resp);
                break;
            case "toUpdate":
                this.toUpdate(req,resp);
                break;
            case "update":
                this.update(req,resp);
                break;
            case "delete":
                this.delete(req,resp);
                break;

        }

    }

    IBooksService booksService=new BooksServiceImpl();



    private void query(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Map<String, Object>> bookList=booksService.listAll();
        req.setAttribute("bookList",bookList);
        req.getRequestDispatcher("/bookList.jsp").forward(req,resp); //跳轉(zhuǎn)到bookList頁面
    }

    private void toAdd(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/add.jsp").forward(req,resp); //跳轉(zhuǎn)到add添加頁面
    }

    private void add(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String bookName=req.getParameter("bookName");
        String author=req.getParameter("author");
        Double price= Double.valueOf(req.getParameter("price"));
        String pubDate=req.getParameter("pubDate");

        Books books=new Books(bookName,author,price, Date.valueOf(pubDate));
        int insert=booksService.insert(books);
        //System.out.println(insert);
        if(insert==1){
            System.out.println("插入成功!");
            this.query(req,resp);
        }else{
            System.out.println("插入失?。?);
        }
    }

    private void toUpdate(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/update.jsp").forward(req,resp);
    }

    private void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int bookId=Integer.parseInt(req.getParameter("bookId"));
        String bookName=req.getParameter("bookName");
        String author=req.getParameter("author");
        Double price= Double.valueOf(req.getParameter("price"));
        String pubDate=req.getParameter("pubDate");

        Books books=new Books(bookId,bookName,author,price, Date.valueOf(pubDate));
        int update=booksService.update(books);
        //System.out.println(update);
        if(update==1){
            System.out.println("修改成功!");
            this.query(req,resp);
            //req.getRequestDispatcher("/bookList.jsp").forward(req,resp);
        }else{
            System.out.println("修改失??!");
        }
    }

    //如果隨機進行修改的話,scanner
    //Scanner scanner=new Scanner(System.in);

    private void delete(HttpServletRequest req, HttpServletResponse resp) {

//        int delete=booksService.delete(5);
//        //System.out.println(delete);
//        if(delete==1){
//            System.out.println("刪除成功!");
//        }else{
//            System.out.println("刪除失?。?);
//        }
    }
    
}

bookList.jsp:

<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/30
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <h1>圖書查詢</h1>
    <%=request.getAttribute("bookList")%>
    <hr/>
    <%
        List<Map<String, Object>> bookList=(List<Map<String, Object>>) request.getAttribute("bookList");
        for(Map<String, Object> book:bookList){
            out.print("<p>");
            out.print(book.get("bookId")+" "+book.get("bookName"));
            out.print("</p>");
        }
    %>
</body>
</html>

add.jsp:

<%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/30
  Time: 18:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form action="<%=request.getContextPath()%>/BooksServlet/add" method="post">
    書名:<input type="text" name="bookName"/> <br/>
    作者:<input type="text" name="author"/><br/>
    價格:<input type="text" name="price"/><br/>
    日期:<input type="text" name="pubDate"/><br/>

    <input type="submit" value="添加"/>
    </form>
</body>
</html>

update.jsp:

<%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/30
  Time: 20:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form action="<%=request.getContextPath()%>/BooksServlet/update" method="post">
        編號:<input type="text" name="bookId"/><br/>
        書名:<input type="text" name="bookName"/> <br/>
        作者:<input type="text" name="author"/><br/>
        價格:<input type="text" name="price"/><br/>
        日期:<input type="text" name="pubDate"/><br/>

        <input type="submit" value="修改"/>
    </form>
</body>
</html>

2.Bootstrap中文網(wǎng)

Bootstraphttps://www.bootcss.com/
圖書管理系統(tǒng)的搭建

實現(xiàn)的效果:

圖書管理系統(tǒng)的搭建

引入

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

代碼:

<%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/31
  Time: 14:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <!--引入bootstrap樣式-->
    <link rel="stylesheet"
          type="text/css"
          href="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"> <!--注意:路徑不要copy錯誤-->

</head>
<body>

    <button type="button" class="btn btn-primary" id="btn" >Primary</button>


    <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal">
        <div class="modal-dialog modal-sm" role="document">
            <div class="modal-content">
                <form>
                    <div class="form-group">
                        <label for="exampleInputEmail1">Email address</label>
                        <input type="email" class="form-control" id="exampleInputEmail1" placeholder="Email">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputPassword1">Password</label>
                        <input type="password" class="form-control" id="exampleInputPassword1" placeholder="Password">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputFile">File input</label>
                        <input type="file" id="exampleInputFile">
                        <p class="help-block">Example block-level help text here.</p>
                    </div>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox"> Check me out
                        </label>
                    </div>
                    <button type="submit" class="btn btn-default">Submit</button>
                </form>
            </div>
        </div>
    </div>

    <!--引入jq-->
    <script type="application/javascript"
            src="<%=request.getContextPath()%>/pugins/1.12.4/jquery-1.12.4.min.js">
    </script>

    <!--引入bootsrapjs-->  <!--彈窗等-->
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/js/bootstrap.min.js">
    </script>

    <script type="text/javascript"> <%--為了保證保持同步,將70703web項目下的out目錄刪掉--%>
        $(function (){
            $("#btn").click(function (){
                $("#usersFrmModal").modal();
            })
        })
    </script>

</body>
</html>

3.使用bootstrap搭建后臺/課堂實例+錄屏/test.html

目錄:

圖書管理系統(tǒng)的搭建

實現(xiàn)的效果:

圖書管理系統(tǒng)的搭建
代碼部分:


<!DOCTYPE>
<html language="zh-cn">
 <head>
	 <title> new document </title>
 
	 <!--1.引入bootstrap的css文件-->
	 <link rel="stylesheet"
	       type="text/css"
		   href="bootstrap-3.3.7-dist/css/bootstrap.min.css"/>

	 <!--2.引入jq文件-->
	 <script type="text/javascript" src="1.12.4/jquery-1.12.4.min.js">
	 </script>

	 <!--3.引入bootstrap js文件-->
	 <script type="text/javascript" 
			 src="bootstrap-3.3.7-dist/js/bootstrap.min.js">
	 </script>


	 <style type="text/css">
		#con
		{
			width:600px;
			margin:50px auto;
		}
	 </style>
	 <script type="text/javascript">
		//定義學生數(shù)據(jù)
		var stus=[
			{no:"S001",name:"張三",phone:"1312312",email:"1@1.com"},
			{no:"S002",name:"李四",phone:"1312312",email:"1@1.com"},
			{no:"S003",name:"王武",phone:"1312312",email:"1@1.com"}
		];

		//顯示學生數(shù)據(jù)
		function showStu()
		{
			//清理之前tbody的數(shù)據(jù)
			$("#tbd").empty();

			//將數(shù)組中的數(shù)據(jù),顯示到表格中
			for(var i=0;i<stus.length;i++)
			{	
				//獲取數(shù)組中的一個數(shù)據(jù)
				var stu = stus[i];

				//定義tr字符串
				var tr;
				tr="<tr>";
				tr+="<td>"+stu.no+"</td>";
				tr+="<td>"+stu.name+"</td>";
				tr+="<td>"+stu.phone+"</td>";
				tr+="<td>"+stu.email+"</td>";
				tr+="</tr>";
				
				//alert(tr);
				//將tr字符串添加到tbody中
				$("#tbd").append(tr);
			}
		}	
		//頁面加載事件
		$(function(){
			//綁定添加按鈕
			$("#btnAdd").click(function(){
				//顯示模態(tài)框
				$(".modal").modal();
			})

			$("#btnStuAdd").click(function(){
				//獲取文本框中的數(shù)據(jù)
				var no = $("#stuNo").val();
				var name = $("#stuName").val();
				var phone = $("#stuPhone").val();
				var email = $("#stuEmail").val();

				//將學生數(shù)據(jù)構(gòu)建為json對象
				var stu = {};
				stu.no=no;
				stu.name=name;
				stu.phone=phone;
				stu.email=email;

				//將學生添加到數(shù)組中
				stus.push(stu);

				//重新顯示學生數(shù)據(jù)
				showStu();

				//讓模態(tài)框隱藏
				$(".modal").modal('hide');
			
			})

			//顯示學生數(shù)據(jù)
			showStu();
		})
	 </script>
 </head>
 <body>
	<div id="con">
		<div class="panel panel-primary">
		  <div class="panel-heading">
			<h3 class="panel-title">學生管理</h3>
		  </div>
		  <div class="panel-body">
				<form class="form-inline">
				  <div class="form-group">
					<input type="text" class="form-control" id="exampleInputName2" placeholder="請輸入姓名">
				  </div>
				  <button type="submit" class="btn btn-primary">搜索</button>
				  <!--primary,info,warning,danger,success-->
				  <button type="button" class="btn btn-success" id="btnAdd">添加</button>
				</form>
				
				<!--表格數(shù)據(jù)-->
				<table class="table table-bordered">
					<thead>
						<tr class="active">
							<th>學號</th>
							<th>姓名</th>
							<th>手機</th>
							<th>郵箱</th>
						</tr>
					</thead>
					<tbody id="tbd">
						<!--
						<tr>
							<td>S001</td>
							<td>張三</td>
							<td>131123123</td>
							<td>1@1.com</td>
						</tr>
						-->
					</tbody>
				</table>

		  </div>
		  <div class="panel-footer">&copy;三門峽</div>
		</div>
	</div>


	<!---模態(tài)框---->
	<div class="modal fade">
	  <div class="modal-dialog">
		<div class="modal-content">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
			<h4 class="modal-title">添加學生</h4>
		  </div>
		  <div class="modal-body">
				<form>
				  <div class="form-group">
					<label for="exampleInputEmail1">學號</label>
					<input type="text" class="form-control" id="stuNo" placeholder="請輸入學號">
				  </div>
				  <div class="form-group">
					<label for="exampleInputPassword1">姓名</label>
					<input type="text" class="form-control" id="stuName" placeholder="請輸入姓名">
				  </div>
				  <div class="form-group">
					<label for="exampleInputFile">手機</label>
					<input type="text" class="form-control" id="stuPhone" placeholder="請輸入手機">
				  </div>
				  <div class="form-group">
					<label for="exampleInputFile">郵箱</label>
					<input type="text" class="form-control" id="stuEmail" placeholder="請輸入郵箱">
				  </div>
				</form>
		  </div>
		  <div class="modal-footer">
			<button type="button" class="btn btn-default" data-dismiss="modal">關(guān)閉</button>
			<button type="button" class="btn btn-primary" id="btnStuAdd">添加</button>
		  </div>
		</div><!-- /.modal-content -->
	  </div><!-- /.modal-dialog -->
	</div><!-- /.modal -->
 </body>
</html>

4.圖書管理系統(tǒng)的搭建(待完善)

實現(xiàn)的效果:

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

代碼修改部分:

在 BooksServlet中增加了toDelete():

package com.servlet;

import com.entity.Books;
import com.service.IBooksService;
import com.service.impl.BooksServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.Date;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

@WebServlet(urlPatterns = "/BooksServlet/*")
public class BooksServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String uri=req.getRequestURI();
        System.out.println("uri: "+uri);
        String url=req.getRequestURL().toString();
        System.out.println("url: "+url);

        String process=uri.substring(uri.lastIndexOf("/")+1);
        System.out.println("截取后: "+process);

        String gp=req.getContextPath();
        System.out.println("gp: "+gp);

        //設置請求數(shù)據(jù)的編碼,避免獲取數(shù)據(jù)亂碼
        req.setCharacterEncoding("utf-8");

        switch (process){
            case "query":
                this.query(req,resp);
                break;
            case "toAdd":
                this.toAdd(req,resp);
                break;
            case "add":
                this.add(req,resp);
                break;
            case "toUpdate":
                this.toUpdate(req,resp);
                break;
            case "update":
                this.update(req,resp);
                break;
            case "toDelete":
                this.toDelete(req,resp);
                break;
            case "delete":
                this.delete(req,resp);
                break;

        }

    }

    IBooksService booksService=new BooksServiceImpl();



    private void query(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        List<Map<String, Object>> bookList=booksService.listAll();
        req.setAttribute("bookList",bookList);
        req.getRequestDispatcher("/bookList.jsp").forward(req,resp); //跳轉(zhuǎn)到bookList頁面
    }

    private void toAdd(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/add.jsp").forward(req,resp); //跳轉(zhuǎn)到add添加頁面
    }

    private void add(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String bookName=req.getParameter("bookName");
        String author=req.getParameter("author");
        Double price= Double.valueOf(req.getParameter("price"));
        String pubDate=req.getParameter("pubDate");

        Books books=new Books(bookName,author,price, Date.valueOf(pubDate));
        int insert=booksService.insert(books);
        //System.out.println(insert);
        if(insert==1){
            System.out.println("插入成功!");
            this.query(req,resp);
        }else{
            System.out.println("插入失??!");
        }
    }

    private void toUpdate(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/update.jsp").forward(req,resp);
    }

    private void update(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int bookId=Integer.parseInt(req.getParameter("bookId"));
        String bookName=req.getParameter("bookName");
        String author=req.getParameter("author");
        Double price= Double.valueOf(req.getParameter("price"));
        String pubDate=req.getParameter("pubDate");

        Books books=new Books(bookId,bookName,author,price, Date.valueOf(pubDate));
        int update=booksService.update(books);
        //System.out.println(update);
        if(update==1){
            System.out.println("修改成功!");
            this.query(req,resp);
            //req.getRequestDispatcher("/bookList.jsp").forward(req,resp);
        }else{
            System.out.println("修改失?。?);
        }
    }

    private void toDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.getRequestDispatcher("/delete.jsp").forward(req,resp);
    }


    private void delete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int bookId= Integer.parseInt(req.getParameter("bookId"));

        int delete=booksService.delete(bookId);
        //System.out.println(delete);
        if(delete==1){
            System.out.println("刪除成功!");
            this.query(req,resp);
        }else{
            System.out.println("刪除失??!");
        }
    }
   
}

增加了delete.jsp:

<%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/31
  Time: 16:36
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
    <form action="<%=request.getContextPath()%>/BooksServlet/delete" method="post">
        編號:<input type="text" name="bookId"/><br/>

        <input type="submit" value="刪除"/>
    </form>
</body>
</html>

在原來及增加的基礎上修改了bookList.jsp:

<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/30
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<html>
<head>
    <title>Title</title>
    <!--引入bootstrap樣式-->
    <link rel="stylesheet"
          type="text/css"
          href="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"> <!--注意:路徑不要copy錯誤-->

    <style>
        #con
        {
            width: 400px;
            /*height: 400px;*/
            border: 2px solid red;
            margin: 0px auto;
        }
    </style>
</head>
<body>
    <h1>圖書查詢</h1>
    <%=request.getAttribute("bookList")%>
    <hr/>

<%--    &lt;%&ndash;    圖書數(shù)據(jù)&ndash;%&gt;--%>
<%--    <div id="con">--%>
<%--        <table class="table table-bordered">--%>
<%--            <thead>--%>
<%--            <tr class="active">--%>
<%--                <th>編號</th>--%>
<%--                <th>圖書</th>--%>
<%--                <th>作者</th>--%>
<%--                <th>價格</th>--%>
<%--                <th>日期</th>--%>
<%--            </tr>--%>
<%--            </thead>--%>
<%--            <tbody id="tbd">--%>
<%--            <tr>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--            </tr>--%>
<%--            <tr>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--            </tr>--%>
<%--            </tbody>--%>
<%--        </table>--%>

<%--    </div>--%>

    <%
        List<Map<String, Object>> bookList=(List<Map<String, Object>>) request.getAttribute("bookList");
        out.print("編號"+"    "+"圖書"+"    "+"作者"+"    "+"價格"+"    "+"日期");
        for(Map<String, Object> book:bookList){
            out.print("<p>");
            out.print(book.get("bookId")+"    "+book.get("bookName")+"    "+book.get("author")+"    "+book.get("price")+"    "+book.get("pubDate"));
            out.print("</p>");
        }

//        for(Map<String, Object> book:bookList){
//            String books="";
//            String tr;
//            tr="<tr>";
//            tr+="<td>"+book.get("bookId")+"</td>";
//            tr+="<td>"+book.get("bookName")+"</td>";
//            tr+="<td>"+book.get("author")+"</td>";
//            tr+="<td>"+book.get("price")+"</td>";
//            tr+="<td>"+book.get("pubDate")+"</td>";
//            tr+="</tr>";
//
//            books=tr;

    %>





<%--    跳轉(zhuǎn)--%>
<%--    使用模態(tài)框之后,《就不需要使用toadd來跳轉(zhuǎn)到add添加頁面的跳轉(zhuǎn)過程了》,直接再booklist中實現(xiàn)添加跳轉(zhuǎn)add()方法的操作--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/add" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        書名:<input type="text" name="bookName"/> <br/>
                        作者:<input type="text" name="author"/><br/>
                        價格:<input type="text" name="price"/><br/>
                        日期:<input type="text" name="pubDate"/><br/>
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-primary" id="btn" >添加</button>

    </form>

<%--    更新--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/update" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal2">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        編號:<input type="text" name="bookId"/><br/>
                        書名:<input type="text" name="bookName"/> <br/>
                        作者:<input type="text" name="author"/><br/>
                        價格:<input type="text" name="price"/><br/>
                        日期:<input type="text" name="pubDate"/><br/>
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-warning" id="btn2" >更改</button>

    </form>

<%--    primary 藍色 info 淺藍色 warning 黃色 danger 紅色 success 綠色--%>

    <%--    刪除--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/delete" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal3">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        編號:<input type="text" name="bookId"/><br/>

                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-danger" id="btn3" >刪除</button>

    </form>



    <!--引入jq-->
    <script type="application/javascript"
            src="<%=request.getContextPath()%>/pugins/1.12.4/jquery-1.12.4.min.js">
    </script>

    <!--引入bootsrapjs-->  <!--彈窗等-->
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/js/bootstrap.min.js">
    </script>

    <script type="text/javascript"> <%--為了保證保持同步,將70703web項目下的out目錄刪掉--%>
        // $(function (){
        //     $("#btn").click(function (){
        //         $("#usersFrmModal").modal();
        //     })
        // })
        //
        // $(function (){
        //     $("#btn2").click(function (){
        //         $("#usersFrmModal2").modal();
        //     })
        // })

    //頁面加載事件
        $(function (){

            //綁定按鈕事件
            $("#btn").click(function (){
                //顯示模態(tài)事件
                $("#usersFrmModal").modal();
            })
            $("#btn2").click(function (){
                $("#usersFrmModal2").modal();
            })
            $("#btn3").click(function (){
                $("#usersFrmModal3").modal();
            })
            //顯示圖書數(shù)據(jù)

            // $("#tbd").append(books);   //拼接暫時實現(xiàn)不了
        })

    </script>


</body>
</html>


5.圖書管理系統(tǒng)的搭建 ①方法一 jstl實現(xiàn)表格

預期效果:

圖書管理系統(tǒng)的搭建

最終實現(xiàn)效果:

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

數(shù)據(jù)庫/表:
圖書管理系統(tǒng)的搭建
添加的jar包/組件:
圖書管理系統(tǒng)的搭建
jar包配置一下
圖書管理系統(tǒng)的搭建

修改的bookList代碼部分:

<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/30
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <!--引入bootstrap樣式-->
    <link rel="stylesheet"
          type="text/css"
          href="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"> <!--注意:路徑不要copy錯誤-->

    <style>
        #con
        {
            width: 400px;
            /*height: 400px;*/
            /*border: 2px solid red;*/
            margin: 0px auto;
        }
    </style>
</head>
<body>
    <h1>圖書查詢</h1>
    <%=request.getAttribute("bookList")%>
    <hr/>

<%--    &lt;%&ndash;    圖書數(shù)據(jù)&ndash;%&gt;--%>
<%--    <div id="con">--%>
<%--        <table class="table table-bordered">--%>
<%--            <thead>--%>
<%--            <tr class="active">--%>
<%--                <th>編號</th>--%>
<%--                <th>圖書</th>--%>
<%--                <th>作者</th>--%>
<%--                <th>價格</th>--%>
<%--                <th>日期</th>--%>
<%--            </tr>--%>
<%--            </thead>--%>
<%--            <tbody id="tbd">--%>
<%--            <tr>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--            </tr>--%>
<%--            <tr>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--                <td>1</td>--%>
<%--            </tr>--%>
<%--            </tbody>--%>
<%--        </table>--%>

<%--    </div>--%>

    <%
        List<Map<String, Object>> bookList=(List<Map<String, Object>>) request.getAttribute("bookList");
//        out.print("編號"+"    "+"圖書"+"    "+"作者"+"    "+"價格"+"    "+"日期");
//        for(Map<String, Object> book:bookList){
//            out.print("<p>");
//            out.print(book.get("bookId")+"    "+book.get("bookName")+"    "+book.get("author")+"    "+book.get("price")+"    "+book.get("pubDate"));
//            out.print("</p>");
//        }

//        for(Map<String, Object> book:bookList){ //(未實現(xiàn)部分代碼)
//            String books="";
//            String tr;
//            tr="<tr>";
//            tr+="<td>"+book.get("bookId")+"</td>";
//            tr+="<td>"+book.get("bookName")+"</td>";
//            tr+="<td>"+book.get("author")+"</td>";
//            tr+="<td>"+book.get("price")+"</td>";
//            tr+="<td>"+book.get("pubDate")+"</td>";
//            tr+="</tr>";
//
//            books=tr;

        request.setAttribute("books",bookList);

    %>

    <table border="1" id="con">
        <tr>
            <th>編號</th>
            <th>圖書</th>
            <th>作者</th>
            <th>價格</th>
            <th>日期</th>
        </tr>
        <c:forEach items="${books}" var="book">
            <tr>
                <td>${book.bookId}</td>
                <td>${book.bookName}</td>
                <td>${book.author}</td>
                <td>${book.price}</td>
                <td>${book.pubDate}</td>
            </tr>
        </c:forEach>
    </table>




<%--    跳轉(zhuǎn)--%>
<%--    使用模態(tài)框之后,《就不需要使用toadd來跳轉(zhuǎn)到add添加頁面的跳轉(zhuǎn)過程了》,直接再booklist中實現(xiàn)添加跳轉(zhuǎn)add()方法的操作--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/add" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        書名:<input type="text" name="bookName"/> <br/>
                        作者:<input type="text" name="author"/><br/>
                        價格:<input type="text" name="price"/><br/>
                        日期:<input type="text" name="pubDate"/><br/>
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-primary" id="btn" >添加</button>

    </form>

<%--    更新--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/update" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal2">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        編號:<input type="text" name="bookId"/><br/>
                        書名:<input type="text" name="bookName"/> <br/>
                        作者:<input type="text" name="author"/><br/>
                        價格:<input type="text" name="price"/><br/>
                        日期:<input type="text" name="pubDate"/><br/>
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-warning" id="btn2" >更改</button>

    </form>

<%--    primary 藍色 info 淺藍色 warning 黃色 danger 紅色 success 綠色--%>

    <%--    刪除--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/delete" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal3">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        編號:<input type="text" name="bookId"/><br/>

                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-danger" id="btn3" >刪除</button>

    </form>



    <!--引入jq-->
    <script type="application/javascript"
            src="<%=request.getContextPath()%>/pugins/1.12.4/jquery-1.12.4.min.js">
    </script>

    <!--引入bootsrapjs-->  <!--彈窗等-->
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/js/bootstrap.min.js">
    </script>

    <script type="text/javascript"> <%--為了保證保持同步,將70703web項目下的out目錄刪掉--%>
        // $(function (){
        //     $("#btn").click(function (){
        //         $("#usersFrmModal").modal();
        //     })
        // })
        //
        // $(function (){
        //     $("#btn2").click(function (){
        //         $("#usersFrmModal2").modal();
        //     })
        // })

    //頁面加載事件
        $(function (){

            //綁定按鈕事件
            $("#btn").click(function (){
                //顯示模態(tài)事件
                $("#usersFrmModal").modal();
            })
            $("#btn2").click(function (){
                $("#usersFrmModal2").modal();
            })
            $("#btn3").click(function (){
                $("#usersFrmModal3").modal();
            })
            //顯示圖書數(shù)據(jù)

            // $("#tbd").append(books);   //拼接暫時實現(xiàn)不了
        })

    </script>


</body>
</html>

5.圖書管理系統(tǒng)的搭建 ②方法二 bootstrap搭建后臺

圖書管理系統(tǒng)的搭建

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建

圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
圖書管理系統(tǒng)的搭建
修改的bookList代碼部分:文章來源地址http://www.zghlxwxcb.cn/news/detail-493033.html

<%@ page import="java.util.Map" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: 33154
  Date: 2022/7/30
  Time: 8:52
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.*" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <!--引入bootstrap樣式-->
    <link rel="stylesheet"
          type="text/css"
          href="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/css/bootstrap.min.css"> <!--注意:路徑不要copy錯誤-->

    <style>
        #con
        {
            width: 400px;
            /*height: 400px;*/
            /*border: 2px solid red;*/
            margin: 0px auto;
        }
    </style>
</head>
<body>
    <h1>圖書查詢</h1>
    <%=request.getAttribute("bookList")%>
    <hr/>

    <%--    圖書數(shù)據(jù)--%>
    <div id="con">
        <table class="table table-bordered">
            <thead>
            <tr class="active">
                <th>編號</th>
                <th>圖書</th>
                <th>作者</th>
                <th>價格</th>
                <th>日期</th>
            </tr>
            </thead>
            <tbody id="tbd">
            <%
                List<Map<String, Object>> bookList=(List<Map<String, Object>>) request.getAttribute("bookList");
//        out.print("編號"+"    "+"圖書"+"    "+"作者"+"    "+"價格"+"    "+"日期");
//        for(Map<String, Object> book:bookList){
//            out.print("<p>");
//            out.print(book.get("bookId")+"    "+book.get("bookName")+"    "+book.get("author")+"    "+book.get("price")+"    "+book.get("pubDate"));
//            out.print("</p>");
//        }

                for(Map<String, Object> book:bookList) { //(未實現(xiàn)部分代碼)
                    String books = "";
                    String tr;
                    tr = "<tr>";
                    tr += "<td>" + book.get("bookId") + "</td>";
                    tr += "<td>" + book.get("bookName") + "</td>";
                    tr += "<td>" + book.get("author") + "</td>";
                    tr += "<td>" + book.get("price") + "</td>";
                    tr += "<td>" + book.get("pubDate") + "</td>";
                    tr += "</tr>";

                    books = tr;
                    out.println(books);
                }

//        request.setAttribute("books",bookList);

            %>
            </tbody>
        </table>

    </div>

<%--    <%--%>
<%--        List<Map<String, Object>> bookList=(List<Map<String, Object>>) request.getAttribute("bookList");--%>
<%--//        out.print("編號"+"    "+"圖書"+"    "+"作者"+"    "+"價格"+"    "+"日期");--%>
<%--//        for(Map<String, Object> book:bookList){--%>
<%--//            out.print("<p>");--%>
<%--//            out.print(book.get("bookId")+"    "+book.get("bookName")+"    "+book.get("author")+"    "+book.get("price")+"    "+book.get("pubDate"));--%>
<%--//            out.print("</p>");--%>
<%--//        }--%>

<%--        for(Map<String, Object> book:bookList) { //(未實現(xiàn)部分代碼)--%>
<%--            String books = "";--%>
<%--            String tr;--%>
<%--            tr = "<tr>";--%>
<%--            tr += "<td>" + book.get("bookId") + "</td>";--%>
<%--            tr += "<td>" + book.get("bookName") + "</td>";--%>
<%--            tr += "<td>" + book.get("author") + "</td>";--%>
<%--            tr += "<td>" + book.get("price") + "</td>";--%>
<%--            tr += "<td>" + book.get("pubDate") + "</td>";--%>
<%--            tr += "</tr>";--%>

<%--            books = tr;--%>
<%--            out.println(books);--%>
<%--        }--%>

<%--//        request.setAttribute("books",bookList);--%>

<%--    %>--%>

<%--    <table border="1" id="con">--%>
<%--        <tr>--%>
<%--            <th>編號</th>--%>
<%--            <th>圖書</th>--%>
<%--            <th>作者</th>--%>
<%--            <th>價格</th>--%>
<%--            <th>日期</th>--%>
<%--        </tr>--%>
<%--        <c:forEach items="${books}" var="book">--%>
<%--            <tr>--%>
<%--                <td>${book.bookId}</td>--%>
<%--                <td>${book.bookName}</td>--%>
<%--                <td>${book.author}</td>--%>
<%--                <td>${book.price}</td>--%>
<%--                <td>${book.pubDate}</td>--%>
<%--            </tr>--%>
<%--        </c:forEach>--%>
<%--    </table>--%>




<%--    跳轉(zhuǎn)--%>
<%--    使用模態(tài)框之后,《就不需要使用toadd來跳轉(zhuǎn)到add添加頁面的跳轉(zhuǎn)過程了》,直接再booklist中實現(xiàn)添加跳轉(zhuǎn)add()方法的操作--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/add" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        書名:<input type="text" name="bookName"/> <br/>
                        作者:<input type="text" name="author"/><br/>
                        價格:<input type="text" name="price"/><br/>
                        日期:<input type="text" name="pubDate"/><br/>
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-primary" id="btn" >添加</button>

    </form>

<%--    更新--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/update" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal2">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        編號:<input type="text" name="bookId"/><br/>
                        書名:<input type="text" name="bookName"/> <br/>
                        作者:<input type="text" name="author"/><br/>
                        價格:<input type="text" name="price"/><br/>
                        日期:<input type="text" name="pubDate"/><br/>
                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-warning" id="btn2" >更改</button>

    </form>

<%--    primary 藍色 info 淺藍色 warning 黃色 danger 紅色 success 綠色--%>

    <%--    刪除--%>
    <form action="<%=request.getContextPath()%>/BooksServlet/delete" method="post">
        <div class="modal fade" tabindex="-1" role="dialog" id="usersFrmModal3">
            <div class="modal-dialog modal-sm" role="document">
                <div class="modal-content">
                    <form>
                        編號:<input type="text" name="bookId"/><br/>

                        <button type="submit" class="btn btn-default">提交</button>
                    </form>
                </div>
            </div>
        </div>
        <button type="button" class="btn btn-danger" id="btn3" >刪除</button>

    </form>



    <!--引入jq-->
    <script type="application/javascript"
            src="<%=request.getContextPath()%>/pugins/1.12.4/jquery-1.12.4.min.js">
    </script>

    <!--引入bootsrapjs-->  <!--彈窗等-->
    <script type="text/javascript"
            src="<%=request.getContextPath()%>/pugins/bootstrap-3.3.7-dist/js/bootstrap.min.js">
    </script>

    <script type="text/javascript"> <%--為了保證保持同步,將70703web項目下的out目錄刪掉--%>
        // $(function (){
        //     $("#btn").click(function (){
        //         $("#usersFrmModal").modal();
        //     })
        // })
        //
        // $(function (){
        //     $("#btn2").click(function (){
        //         $("#usersFrmModal2").modal();
        //     })
        // })

    //頁面加載事件
        $(function (){

            //綁定按鈕事件
            $("#btn").click(function (){
                //顯示模態(tài)事件
                $("#usersFrmModal").modal();
            })
            $("#btn2").click(function (){
                $("#usersFrmModal2").modal();
            })
            $("#btn3").click(function (){
                $("#usersFrmModal3").modal();
            })
            //顯示圖書數(shù)據(jù)

            // $("#tbd").append(books);   //拼接暫時實現(xiàn)不了
        })

    </script>


</body>
</html>







到了這里,關(guān)于圖書管理系統(tǒng)的搭建的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關(guān)文章

  • 第二章:項目環(huán)境搭建【基于Servlet+JSP的圖書管理系統(tǒng)】

    第二章:項目環(huán)境搭建【基于Servlet+JSP的圖書管理系統(tǒng)】

    02-圖書管理系統(tǒng)-項目環(huán)境搭建 ??本項目涉及到的工具都有在云盤提供,自行下載即可 JDK8 IDEA2021 Tomcat8.5 MySQL的客戶端工具SQLYog … ??通過IDEA創(chuàng)建maven項目。勾選腳手架工具。選擇 maven-archetype-webapp 設置項目的基礎信息 3.1 JDK配置 ??JDK使用的是JDK8。我們也需要配置下:

    2024年02月11日
    瀏覽(25)
  • 【python基礎知識】14.圖書管理系統(tǒng)的搭建(類與對象實操)

    【python基礎知識】14.圖書管理系統(tǒng)的搭建(類與對象實操)

    通過這個項目希望你可以學會用類與實例的方法編寫程序,掌握面向?qū)ο缶幊痰幕舅季S,為日后能處理更復雜的代碼結(jié)構(gòu)打牢基礎。 我曾跟你提過,學Python,做項目是進步最快的。我沒說的是:做項目總會遇到種種困難,想不通的邏輯,頻頻報錯的代碼。 所以,如果你在今

    2024年02月02日
    瀏覽(52)
  • Java web圖書管理系統(tǒng)、在線圖書借閱管理系統(tǒng)(帶文檔)

    Java web圖書管理系統(tǒng)、在線圖書借閱管理系統(tǒng)(帶文檔)

    ?大家好,我是DeBug,很高興你能來閱讀!作為一名熱愛編程的程序員,我希望通過這些教學筆記與大家分享我的編程經(jīng)驗和知識。在這里,我將會結(jié)合實際項目經(jīng)驗,分享編程技巧、最佳實踐以及解決問題的方法。無論你是初學者還是有一定經(jīng)驗的程序員,我都希望能夠為你

    2024年01月23日
    瀏覽(25)
  • 圖書管理系統(tǒng)|基于Springboot的圖書管理系統(tǒng)設計與實現(xiàn)(源碼+數(shù)據(jù)庫+文檔)

    圖書管理系統(tǒng)|基于Springboot的圖書管理系統(tǒng)設計與實現(xiàn)(源碼+數(shù)據(jù)庫+文檔)

    圖書管理系統(tǒng)目錄 目錄 基于Springboot的圖書管理系統(tǒng)設計與實現(xiàn) 一、前言 二、系統(tǒng)功能設計 三、系統(tǒng)實現(xiàn) 1、個人中心 2、管理員管理 3、用戶管理 4、圖書出版社管理 四、數(shù)據(jù)庫設計 1、實體ER圖 五、核心代碼? 六、論文參考 七、最新計算機畢設選題推薦 八、源碼獲?。?/p>

    2024年03月26日
    瀏覽(30)
  • 圖書借閱管理系統(tǒng)

    圖書借閱管理系統(tǒng)

    1、系統(tǒng)概述 圖書借閱管理系統(tǒng)由管理員系統(tǒng)和用戶系統(tǒng)兩個子系統(tǒng)構(gòu)成。用戶運行程序后可按程序說明進入子系統(tǒng),輸入“1”進入管理員系統(tǒng),輸入“2”進入用戶系統(tǒng)。圖書信息和讀者信息均用文件存儲。?? 管理員系統(tǒng): 新增圖書:管理員可輸入圖書的類別、書號、書名

    2024年02月05日
    瀏覽(22)
  • 云借閱-圖書管理系統(tǒng)

    云借閱-圖書管理系統(tǒng)

    程序設計邏輯簡單,適合觀摩學習使用。 云借閱圖書管理系統(tǒng)主要實現(xiàn)了兩大功能模塊:用戶登錄模塊和圖書管理模塊,用戶登錄模塊主要用于實現(xiàn)用戶的登錄與注銷;圖書管理模塊主要用于管理圖書,如新書推薦、圖書借閱等。 1.開發(fā)技術(shù): 后端:SSM(Spring、SpringMVC、Mybatis

    2024年02月13日
    瀏覽(22)
  • 圖書管理系統(tǒng)項目測試

    圖書管理系統(tǒng)項目測試

    添加依賴如下: 在被測試類中使用快捷鍵 Ctrl+Shift+T,選擇要測試的方法,編寫測試類,完成單元測試。 (1)登錄: 1.輸入正確的賬號密碼,是否正確登錄并跳轉(zhuǎn)至主頁面 2.賬號為空,輸入密碼,是否提示輸入密碼 3.輸入賬號,密碼為空,是否提示輸入用戶名 4.賬號密碼均為

    2024年02月11日
    瀏覽(21)
  • 圖書管理系統(tǒng) (javaweb)

    圖書管理系統(tǒng) (javaweb)

    聲明一下 這個圖書館管理系統(tǒng)為我 自己 研究制作 而且我本人的英語不好 ,在一些類的命名可能很怪所以請大佬們請勿嘲笑 而且我本人是一位大一學生,代碼說不上有多精明 ,我本人在前端的制作方面可能不是很熟練QAQ 用戶的登錄以及注冊 對書籍的增刪查以及分頁 maven

    2024年02月05日
    瀏覽(24)
  • 云借閱圖書管理系統(tǒng)

    云借閱圖書管理系統(tǒng)

    ? ? ? ? ?基于SSM(Spring + Spring MVC + Mybatis)框架開發(fā)的一個較為簡單的云借閱圖書管理系統(tǒng),雖然比較簡單,但是耐心的做完會對? Spring框架 和 Spring MVC框架 以及 Mybatis 框架? 這三個框架的整合開發(fā)有一個較好的理解 。 下面我就來簡單的研究一下代碼,全部的代碼文件,我

    2024年02月06日
    瀏覽(21)
  • 圖書管理系統(tǒng)(簡易版)

    圖書管理系統(tǒng)(簡易版)

    目錄 一、該圖書管理系統(tǒng)涉及Java的知識點 二、該圖書管理系統(tǒng)包含的功能 數(shù)組的增刪查 抽象類 接口 面向?qū)ο蟮姆庋b、繼承和多態(tài) 圖書管理系統(tǒng)的使用人群分為兩種:①管理人員,②普通用戶 具體實現(xiàn):抽象類的繼承 User類(父類): AdminUser類(管理員) ?NormalUser類(普通用

    2024年02月08日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包