实验五~JDBC数据库访问与DAO设计模式

news2025/1/10 10:36:44

1. 使用传统JDBC方法与Model 1模型通过JSP页面访问数据库。

【步骤1】在MySQL数据库test中创建books表,其结构如下:

创建数据库MySQL代码与插入数据代码

drop database if exists web_test;
create database web_test character set utf8mb4;

use web_test;

create table books(
    book_id varchar(10) not null,
    title varchar(50),
    author varchar(20),
    publisher varchar(40),
    price float
);
insert into books values ('204', 'Head First Servlets & JSP', 'Bryan Basham', '中国电力出版社', 98);
insert into books values ('201', 'Servlets与JSP核心教程', 'Hall Marty', '清华大学出版社', 45);
insert into books values ('202', 'Tomcat与Java Web 开发技术详解', '孙卫琴', '机械工业出版社', 45);
insert into books values ('203', 'JSP 应用开发技术', '柳永坡', '人民邮电出版社', 52);
insert into books values ('205', 'J2EE 1.4 编程指南', 'Spielman Sue', '电子工业出版社', 68);

 【步骤2】创建模型:编写名称为BookBean.java的JavaBean用于封装图书的信息;编写BookDAO.java,采用传统JDBC方法创建数据库连接,对图书信息进行查询。

DBUtil的代码 

package org.example.utils;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class DBUtil {
    private static volatile DataSource DS;
    private static DataSource getDataSource() {
        if (DS == null) {
            synchronized (DBUtil.class) {
                if (DS == null) {
                    MysqlDataSource dataSource = new MysqlDataSource();
                    dataSource.setURL("jdbc:mysql://localhost:3306/web_test");
                    dataSource.setUser("root");//账号
                    dataSource.setPassword("142516");
                    dataSource.setUseSSL(false);//不设置不会出现问题,但会出现红色警告
                    //数据库的编码格式,可以设置为UTF-8,或是utf8
                    dataSource.setCharacterEncoding("utf8");
                    DS = dataSource;
                }
            }
        }
        return DS;
    }
    //获取数据库连接
    public static Connection getConnection() {
        try {
            return getDataSource().getConnection();
        } catch (SQLException e) {
            throw new RuntimeException("获取数据库连接异常", e);
        }
    }
    //释放连接
    public static void close(java.sql.Connection c, Statement s, ResultSet rs) {
        try {
            if(rs != null) rs.close();
            if(s != null) s.close();
            if(c != null) c.close();
        } catch (SQLException e) {
            throw new RuntimeException("jdbc释放资源出错", e);
        }
    }
}

上面这部分需要改一下

BookBean代码 

package org.example.beans;

public class BookBean {
    private String bookId;
    private String title;
    private String author;
    private String publisher;
    private double price;

    public String getBookId() {
        return bookId;
    }

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

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

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

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public double getPrice() {
        return price;
    }

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

BookDao代码 

package org.example.dao;

import org.example.beans.BookBean;
import org.example.utils.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

public class BookDao {
    public static List<BookBean> queryBooks() {
        Connection c = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            c = DBUtil.getConnection();
            String sql = "select * from books";
            ps = c.prepareStatement(sql);
            rs = ps.executeQuery();
            List<BookBean> books = new ArrayList<>();
            while (rs.next()) {
                BookBean b = new BookBean();
                b.setBookId(rs.getString("book_id"));
                b.setAuthor(rs.getString("author"));
                b.setTitle(rs.getString("title"));
                b.setPublisher(rs.getString("publisher"));
                b.setPrice(rs.getDouble("price"));
                books.add(b);
            }
            return books;
        } catch (Exception e) {
            throw new RuntimeException("查询books出错", e);
        } finally {
            DBUtil.close(c, ps, rs);
        }
    }
}

【步骤3】创建兼具视图与控制器功能的JSP页面:编写displayBooks.jsp页面,使用<jsp:useBean>动作调用BookDAO查询所有图书的信息,以表格的形式显示所有图书的书号、书名、作者、价格和出版社名称。

displayBooks.jsp 

<%@ page import="java.util.*" %>
<%@ page import="org.example.beans.*" %>
<%@ page contentType="text/html;charset=utf-8" %>
<jsp:useBean id="book" class="org.example.dao.BookDao" scope="session"/>
<html>
<head>
    <title>displayBooks</title>
<style>
    td{
        text-align: center;
    }
</style>
</head>
<body>
    <table width="500" height="256" border="1" align="center">
        <tr>
        <th scope="col">bookid</th>
        <th scope="col">title</th>
        <th scope="col">author</th>
        <th scope="col">publisher</th>
        <th scope="col">price</th>
    </tr>
    <%
        List<BookBean> books = book.queryBooks();
        int len = books.size();
        for (int i = 0; i < len; i++) {
            String book_id = books.get(i).getBookId();
            String title = books.get(i).getTitle();
            String author = books.get(i).getAuthor();
            String publisher = books.get(i).getPublisher();
            double price = books.get(i).getPrice();
            %>
            <tr>
                <td><%=book_id%> </td>
                <td><%=title%></td>
                <td><%=author%></td>
                <td><%=publisher%></td>
                <td><%=price%></td>
            </tr>
        <% } %>
    </table>
</body>
</html>

 2. 基于实验内容1创建的数据库表和模型,采用MVC设计模式,通过数据源和DAO对象访问数据库。其中JavaBeans实现模型与数据库访问与操作,Servlet实现控制器,JSP页面实现视图。

  • 模型包括2个JavaBean:BookBean用于存放图书信息,BookDAO用于访问数据库。

 BookBean.java(BookBean与上面的BookBean一样)

package org.example.beans;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 17:57
 */
//@SuppressWarnings("serial")
public class BookBean {
    private String bookId;
    private String title;
    private String author;
    private String publisher;
    private double price;

    public String getBookId() {
        return bookId;
    }

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

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAuthor() {
        return author;
    }

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

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public double getPrice() {
        return price;
    }

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

 BookDao.java(BookDao在上面的java文件中额外加了几个方法)

package org.example.dao;

import org.example.beans.BookBean;
import org.example.utils.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 18:13
 */
public class BookDao {
    public static List<BookBean> queryBooks() {
        Connection c = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            c = DBUtil.getConnection();
            String sql = "select * from books";
            ps = c.prepareStatement(sql);
            rs = ps.executeQuery();
            List<BookBean> books = new ArrayList<>();
            while (rs.next()) {
                BookBean b = new BookBean();
                b.setBookId(rs.getString("book_id"));
                b.setAuthor(rs.getString("author"));
                b.setTitle(rs.getString("title"));
                b.setPublisher(rs.getString("publisher"));
                b.setPrice(rs.getDouble("price"));
                books.add(b);
            }
            return books;
        } catch (Exception e) {
            throw new RuntimeException("查询books出错", e);
        } finally {
            DBUtil.close(c, ps, rs);
        }
    }
    //根据序号查询
    public static BookBean queryById(String id) {
        Connection c = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        BookBean b = null;
        try {
            c = DBUtil.getConnection();
            String sql = "select * from books where book_id = ?";
            ps = c.prepareStatement(sql);
            ps.setString(1, id);
            rs = ps.executeQuery();
            while (rs.next()) {
                b = new BookBean();
                b.setBookId(rs.getString("book_id"));
                b.setAuthor(rs.getString("author"));
                b.setTitle(rs.getString("title"));
                b.setPublisher(rs.getString("publisher"));
                b.setPrice(rs.getDouble("price"));
            }
            return b;
        } catch (Exception e) {
            throw new RuntimeException("查询books出错", e);
        } finally {
            DBUtil.close(c, ps, rs);
        }
    }

    //根据书名查询
    public static BookBean queryByTitle(String title) {
        Connection c = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        BookBean b = null;
        try {
            c = DBUtil.getConnection();
            String sql = "select * from books where title = ?";
            ps = c.prepareStatement(sql);
            ps.setString(1, title);
            rs = ps.executeQuery();
            while (rs.next()) {
                b = new BookBean();
                b.setBookId(rs.getString("book_id"));
                b.setAuthor(rs.getString("author"));
                b.setTitle(rs.getString("title"));
                b.setPublisher(rs.getString("publisher"));
                b.setPrice(rs.getDouble("price"));
            }
            return b;
        } catch (Exception e) {
            throw new RuntimeException("查询books出错", e);
        } finally {
            DBUtil.close(c, ps, rs);
        }
    }
    //根据作者查询
    public static BookBean queryByAuthor(String author) {
        Connection c = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        BookBean b = null;
        try {
            c = DBUtil.getConnection();
            String sql = "select * from books where author = ?";
            ps = c.prepareStatement(sql);
            ps.setString(1, author);
            rs = ps.executeQuery();
            while (rs.next()) {
                b = new BookBean();
                b.setBookId(rs.getString("book_id"));
                b.setAuthor(rs.getString("author"));
                b.setTitle(rs.getString("title"));
                b.setPublisher(rs.getString("publisher"));
                b.setPrice(rs.getDouble("price"));
            }
            return b;
        } catch (Exception e) {
            throw new RuntimeException("查询books出错", e);
        } finally {
            DBUtil.close(c, ps, rs);
        }
    }
    //插入数据
    public static int insert(BookBean book) {
        Connection c = null;
        PreparedStatement ps = null;
        try {
            c = DBUtil.getConnection();
            String sql = "insert into books values (?, ?, ?, ?, ?);";
            ps = c.prepareStatement(sql);
            ps.setString(1, book.getBookId());
            ps.setString(2, book.getTitle());
            ps.setString(3, book.getAuthor());
            ps.setString(4, book.getPublisher());
            ps.setDouble(5, book.getPrice());
            return ps.executeUpdate();
        } catch (Exception e) {
            throw new RuntimeException("插入books出错", e);
        } finally {
            DBUtil.close(c, ps, null);
        }
    }
}

  • 控制器包括2个Servlet:BookQueryServlet根据请求参数查询图书信息、BookInsertServlet用来向数据库中插入一条图书信息。

BookQueryServlet.java

package org.example.servlet;

import org.example.beans.BookBean;
import org.example.dao.BookDao;

import javax.servlet.RequestDispatcher;
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;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 20:12
 */
@WebServlet("/query")
public class BookQueryServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.setCharacterEncoding("utf-8");
        String selection = req.getParameter("selection");
        String content = req.getParameter("content");
        BookBean book = null;
        if (selection.equals("book_id")) {
            book = BookDao.queryById(content);
        } else if (selection.equals("title")) {
            book = BookDao.queryByTitle(content);
        } else {
            book = BookDao.queryByAuthor(content);
        }
        if(book!=null){
            req.getSession().setAttribute("book", book);
            RequestDispatcher view = req.getRequestDispatcher("display.jsp");
            view.forward(req, resp);
        }else{
            RequestDispatcher view = req.getRequestDispatcher("errorPage.jsp");
            view.forward(req, resp);
        }
    }
}

BookInsertServlet.java

package org.example.servlet;

import org.example.beans.BookBean;
import org.example.dao.BookDao;

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.io.PrintWriter;
import java.util.Date;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 20:12
 */
@WebServlet("/insert")
public class BookInsertServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        BookBean book = new BookBean();
        book.setBookId(req.getParameter("bookId"));
        book.setTitle(req.getParameter("title"));
        book.setAuthor(req.getParameter("author"));
        book.setPublisher(req.getParameter("publisher"));
        book.setPrice(Double.parseDouble(req.getParameter("price")));
        System.out.println(book.getTitle());
        int ret = BookDao.insert(book);
        String respContent = "插入失败";
        if (ret == 1) {
            respContent = "插入成功";
        }
        PrintWriter out = resp.getWriter();
        out.println("<HTML>");
        out.println("  <BODY><center>");
        out.println("<h2>"+respContent + "</h2>");
        out.println(" </center> </BODY>");
        out.println("</HTML>");
    }
}

  • 视图包括4个JSP页面:bookQuery.jsp显示图书查询表单的页面、bookInsert.jsp显示收集图书信息表单的页面、display.jsp显示查询结果页面、errorPage.jsp显示查询错误页面。

bookQuery.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<head>
    <title>bookQuery</title>
</head>
<body>
    <form action="query" method="post">
        请做选择:<select name="selection">
            <option value="book_id">序号</option>
            <option value="title">书名</option>
            <option value="author">作者</option>
        </select>
        <br>
        查询内容:<input type="text" name="content">
        <input type="submit" value="查询">
    </form>
</body>
</html>

bookInsert.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="book" class="org.example.beans.BookBean" scope="session"/>
<html>
<head>
    <title>bookInsert</title>
</head>
<body>
<h3>请输入图书信息:</h3>
<form action="insert" method="post">
    <table>
        <tr><td>书号</td> <td><input type="text" name="bookId" ></td></tr>
        <tr><td>书名</td><td><input type="text" name="title"></td></tr>
        <tr><td>作者</td><td><input type="text" name="author" ></td></tr>
        <tr><td>出版社</td><td><input type="text" name="publisher" ></td></tr>
        <tr><td>单价</td><td><input type="text" name="price" ></td></tr>
        <tr><td><input type="submit" value="确定" ></td>
            <td><input type="reset" value="重置" ></td>
        </tr>
    </table>
</form>
</body>
</html>

display.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="book" class="org.example.beans.BookBean" scope="session"/>
<jsp:setProperty name="book" property="*"/>
<html>
<head>
    <title>display</title>
</head>
<body>
书号:<jsp:getProperty name="book" property="bookId"/><br><br>
书名:<jsp:getProperty name="book" property="title"/><br><br>
作者:<jsp:getProperty name="book" property="author"/><br><br>
出版社:<jsp:getProperty name="book" property="publisher"/><br><br>
价格:<jsp:getProperty name="book" property="price"/><br><br>
</body>
</html>

errorPage.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>errorPage</title>
</head>
<body>
Sorry,未查询到您需要的图书!
</body>
</html>

3. DAO设计模式练习。 

【步骤1】:使用root用户登录MySQL的test数据库,创建customer表,包括custName、email、phone等字段,设计CustomerBean传输对象,使其实现java.io.Serializable接口。

创建数据库代码

create table customer(
    custName varchar(20),
    email varchar(40),
    phone varchar(20)
);

 CustomerBean.java

package org.example.beans;

import java.io.Serializable;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 21:49
 */
@SuppressWarnings("serial")
public class CustomerBean implements Serializable {
    private String custName;
    private String email;
    private String phone;

    public String getCustName() {
        return custName;
    }

    public void setCustName(String custName) {
        this.custName = custName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }
}

【步骤2】:创建CustomerDAO类实现数据库访问逻辑,通过该类可以获得一个连接对象,对数据库进行查询、插入、修改和删除操作,最后关闭指定的对象。

package org.example.dao;

import org.example.beans.BookBean;
import org.example.beans.CustomerBean;
import org.example.utils.DBUtil;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 21:57
 */
public class CustomerDAO {
    //查询数据
    public static List<CustomerBean> queryCustomer() {
        Connection c = null;
        PreparedStatement ps = null;
        ResultSet rs = null;
        try {
            c = DBUtil.getConnection();
            String sql = "select * from customer";
            ps = c.prepareStatement(sql);
            rs = ps.executeQuery();
            List<CustomerBean> customers = new ArrayList<>();
            while (rs.next()) {
                CustomerBean customer = new CustomerBean();
                customer.setCustName(rs.getString("custName"));
                customer.setEmail(rs.getString("email"));
                customer.setPhone(rs.getString("phone"));
                customers.add(customer);
            }
            return customers;
        } catch (Exception e) {
            throw new RuntimeException("查询customer出错", e);
        } finally {
            DBUtil.close(c, ps, rs);
        }
    }
    //插入数据
    public static int insert(CustomerBean customer) {
        Connection c = null;
        PreparedStatement ps = null;
        try {
            c = DBUtil.getConnection();
            String sql = "insert into customer values (?, ?, ?);";
            ps = c.prepareStatement(sql);
            ps.setString(1, customer.getCustName());
            ps.setString(2, customer.getEmail());
            ps.setString(3, customer.getPhone());
            return ps.executeUpdate();
        } catch (Exception e) {
            throw new RuntimeException("插入books出错", e);
        } finally {
            DBUtil.close(c, ps, null);
        }
    }
    //根据name删除数据
    public static int delete(String name) {
        Connection c = null;
        PreparedStatement ps = null;
        try {
            c = DBUtil.getConnection();
            String sql = "delete from customer where custName=?";
            ps = c.prepareStatement(sql);
            ps.setString(1, name);
            return ps.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException("删除数据库图片出错", e);
        } finally {
            DBUtil.close(c, ps, null);
        }
    }
    //修改数据
    public static int update(CustomerBean customer) {
        Connection c = null;
        PreparedStatement ps = null;
        try {
            c = DBUtil.getConnection();
            String sql = "update customer set custName=?,email=?,phone=?";
            ps = c.prepareStatement(sql);
            ps.setString(1, customer.getCustName());
            ps.setString(2, customer.getEmail());
            ps.setString(3, customer.getPhone());
            return ps.executeUpdate();
        } catch (SQLException e) {
            throw new RuntimeException("修改数据异常", e);
        } finally {
            DBUtil.close(c, ps, null);
        }
    }
}

【步骤3】:创建insertCustomer.jsp页面,通过一个表单录入向数据库中插入的数据。

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>insertCustomer</title>
</head>
<body>
<h3>请输入顾客信息:</h3>
<form action = "insertCustomer" method = "post">
    <table>
        <tr><td>姓名</td> <td><input type="text" name="custName" ></td></tr>
        <tr><td>邮箱</td><td><input type="text" name="email"></td></tr>
        <tr><td>电话</td><td><input type="text" name="phone" ></td></tr>
        <tr><td><input type="submit" value="确定" ></td>
            <td><input type="reset" value="重置" ></td>
        </tr>
    </table>
</form>
</body>
</html>

【步骤4】:创建InsertCustomerServlet.java控制器,调用CustomerDAO对象和传输对象,将数据插入到数据库中。

package org.example.servlet;

import org.example.beans.BookBean;
import org.example.beans.CustomerBean;
import org.example.dao.BookDao;
import org.example.dao.CustomerDAO;

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.io.PrintWriter;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Li_yizYa
 * Date: 2023—04—24
 * Time: 21:56
 */
@WebServlet("/insertCustomer")
public class InsertCustomerServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setContentType("text/html;charset=utf-8");
        CustomerBean customer = new CustomerBean();
        customer.setCustName(req.getParameter("custName"));
        customer.setEmail(req.getParameter("email"));
        customer.setPhone(req.getParameter("phone"));
        int ret = CustomerDAO.insert(customer);
        String respContent = "插入失败";
        if (ret == 1) {
            respContent = "插入成功";
        }
        PrintWriter out = resp.getWriter();
        out.println("<HTML>");
        out.println("  <BODY><center>");
        out.println("<h2>"+respContent + "</h2>");
        out.println(" </center> </BODY>");
        out.println("</HTML>");
    }
}

【步骤5】:创建showCustmer.jsp,显示所有客户的信息,每一条客户信息后面增加修改和删除超链接,编写ActionServlet.java控制器,调用DAO和传输对象实现对客户信息的删除和修改功能。

showCustmer.jsp

<%@ page import="java.util.*" %>
<%@ page import="org.example.beans.*" %>
<%@ page contentType="text/html;charset=utf-8" %>
<jsp:useBean id="customer" class="org.example.dao.CustomerDAO" scope="session"/>
<html>
<head>
    <title>showCustmer</title>
<style>
    td{
        text-align: center;
    }
</style>
</head>
<body>
    <table width="500" height="256" border="1">
        <tr>
        <th scope="col">客户姓名</th>
        <th scope="col">邮箱</th>
        <th scope="col">电话号</th>
        <th scope="col">操作</th>
    </tr>
    <%
        List<CustomerBean> customers = customer.queryCustomer();
        int len = customers.size();
        for (int i = 0; i < len; i++) {
            String custName = customers.get(i).getCustName();
            String email = customers.get(i).getEmail();
            String phone = customers.get(i).getPhone();
            %>
            <tr>
                <td><%=custName%> </td>
                <td><%=email%></td>
                <td><%=phone%></td> 
                <td>
                    <a href="aciton">修改</a>
                    <a href="action">删除</a>
                </td> 
            </tr>
        <% } %>
    </table>
</body>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/457868.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

oralce数据库定时备份

windows服务器中&#xff0c;定时备份数据库&#xff08;全量备份&#xff09;。 创建一个bat文件&#xff0c;内容为&#xff1a; set dd%date:~8,2% set mm%date:~5,2% set yy%date:~0,4% set folder%yy%-%mm%-%dd% md D:\db_backup\%folder% exp db_name/db_pwd127.0.0.1/or…

为了写markdown文件,Windows下的noevim配置

vim安装插件 在网页上写CSDN文章有诸多不便&#xff0c;感觉vim很好用&#xff0c;可是vim中没有预览功能。按照网上找到的教程安装插件&#xff0c;将以下代码复制的到_vimrc文件中。 set rtp$VIM/vimfiles/bundle/Vundle.vim/ call vundle#begin(./vimfiles/bundle/)"…

4.3调整基类成员在派生类中的访问属性的方法

同名成员 在定义派生类的时候&#xff0c;C语言允许派生类与基类中的函数名相同。如果在派生类中定义了与基类中相同的成员&#xff0c;则称派生类成员覆盖了基类的同名成员&#xff0c;在派生类中使用这个名字意味着访问在派生类中重新说明的成员。为了在派生类中使用基类的同…

瑞吉外卖-项目笔记

文章目录 1.业务开发day011.软件开发整体介绍2.项目整体介绍:star:3.开发环境搭建4.登录功能&#xff1a;star4.1代码实现 5.退出功能6.页面效果出现 day021.完善登录功能2.新增员工功能 1.业务开发 day01 1.软件开发整体介绍 2.项目整体介绍⭐️ 后端&#xff1a;管理菜品和…

车载以太网 - SomeIP - 协议用例 - Format_02

目录 11、验证SomeIP-SD Resvered字段设置为0x000000 13、验证SomeIP-SD Entry Type类型设置为0x01(提供服务)

基于脉搏波信号和人工智能方法的应用

目录 一、引言 二、脉搏波信号基本原理和特点 2.1 脉搏波信号的产生和传播 2.2 脉搏波信号的特征参数 三、人工智能技术在脉搏波信号处理中的应用 3.1 传统机器学习方法 3.2 深度学习方法 四、基于深度学习的脉搏波信号处理方法 4.1 数据预处理 4.2 深度学习模型构建…

写题总结1

先把自己写完的总结一下&#xff1a; 题目一&#xff1a; 猫儿园的告示牌上贴着 ab 大小的矩形广告纸。猫猫对广告不感兴趣&#xff0c;她想知道能否用 cd 的矩形白纸完全覆盖这个广告。猫猫可以对白纸进行平移、旋转&#xff0c;但不能折叠或撕开等。如果可以完全覆盖输出 YE…

【音视频第17天】RTSP、RTMP协议初识

被叫去搞直播了&#xff0c;悲喜交加。先学习一下基本的技术栈&#xff0c;RTSP RTMP HTTP 先简单随便看看吧。 目录 什么是流媒体协议RTMPRTMP 工作原理 RTSPRTSP 工作原理 RTMP 与 RTSP 区别详细看看RTSP简介RTSP交互流程OPTIONSDESCRIBESETUPPLAYPAUSESET_PARAMETERGET_PAR…

代码随想录算法训练营第四十一天|343. 整数拆分、96.不同的二叉搜索树

文章目录 343. 整数拆分96.不同的二叉搜索树:star: 343. 整数拆分 题目链接&#xff1a;代码随想录 本题就是一个个递推&#xff0c;通过将dp[i]定义为第i个值的最大乘积 然后最大乘积有两种来源&#xff0c;一个是(i - j) * j 还有一种是dp[i - j] * j; 解题思路&#xff1a;…

Nautilus Chain :基于模块化架构的Layer3正在走向成熟

Nautilus Chain是一个基于Eclipse和Celestia构建的模块化Layer3链。作为定位在Layer0的链基建概念&#xff0c;Eclipse和Celestia为面向未来的区块链扩容技术提供了一套开发工具和基础框架。尽管这种前沿技术过去一直处于概念验证阶段&#xff0c;尚未推出适用于大规模应用的成…

【消息队列】Kafka请求如何被处理的

前言 对于Kafka来说&#xff0c;分为几个阶段&#xff0c;一个是消息的生产请求&#xff0c;以及对应的消息的消费请求。一个是生产者发送到Broker&#xff0c;另一个是消费者通过pull的方式 请求Broker&#xff0c;那么Broker是如何处理这几个请求的。细分下来主要常见的是如…

OFDM-LS信道估计 MMSE信道估计公式推导

假设ofdmN个子载波之间是完全正交的&#xff0c;即不考虑ICI影响&#xff0c;通过发送训练序列来实现信道估计。 其中&#xff0c;在推导6.8的时候&#xff0c;需要将6.6先拆解一下。 X − 1 Y X − 1 ( X H Z ) X − 1 X H X − 1 Z H X − 1 Z X^{-1}Y X^{-1}(XHZ)…

【难学易用c++ 之 继承】

目录&#xff1a; 前言一、继承的概念及定义&#xff08;一&#xff09;概念&#xff08;二&#xff09;继承定义继承关系和访问限定符继承基类成员访问方式的变化 二、基类和派生类对象赋值转换三、继承中的作用域四、派生类的默认成员函数五、继承与友元六、继承与静态成员七…

TiDB实战篇-常用的高可用架构

简介 TiDB实战篇-常用的高可用架构。 高可用要考虑的问题 同城三中心 RTO<35秒 RPO0(因为一个数据中心挂点了&#xff0c;还有其他两个可以提供服务) (优点)数据副本不能在同一个数据中心&#xff08;raft多数存活&#xff09;&#xff08;PD的label标签能够解决这个问题…

OpenCV基础之常见的图像梯度算子

文章目录 OpenCV基础之常见的图像梯度Roberts交叉算子Prewitt算子Sobel算子Laplacian算子 OpenCV基础之常见的图像梯度 梯度是一个向量&#xff0c;梯度方向指向函数变化最快的方向&#xff0c;大小就是它的模&#xff0c;也是最大的变化率。 图像梯度是指在图像中某个位置处沿…

关于容器(Docker)的形象比喻

1 将容器比喻为样板间 容器是一种特殊的进程 容器依赖与Linux操作系统内核的几项技术&#xff1a;namespace、cgroup、chroot namespace 与编程语言里的 namespace 有点类似&#xff0c;它可以创建出独立的文件系统、主机名、进程号、网络等资源空间&#xff0c;相当于给进程…

回归问题(Regression)

Regression 前言Dependent vs. Explanatory VariablesHandle Numerical Labelssquared error和variance什么区别 Linear RegressionLinear Regression in 1 Dimension Least Squares &#xff08;最小二乘&#xff0c;重点&#xff09;Least Squares ObjectiveMinimizing a Dif…

确保软件项目成功——验收测试指南

确保软件项目成功——验收测试指南 在软件项目验收测试中&#xff0c;软件测试报告是非常重要的一部分&#xff0c;需要准备和提交。以山东省在2021印发的《政府采购履约验收管理办法》为例&#xff1a; 省级各国家机关、事业单位和团体组织&#xff08;以下统称“采购人”&…

会话跟踪——JWT令牌

会话指的是浏览器与服务器之间的一次连接&#xff0c;我们称之为一次会话。 在用户打开浏览器第一个访问服务器的时候&#xff0c;这个会话就建立了&#xff0c;只要有任何一方断开连接&#xff0c;此时会话就结束了。再一次会话中是可以包含多次请求和相应。那什么是会话跟踪呢…

动力节点springsecurity笔记14~18SpringSecurity 集成thymeleaf

15 SpringSecurity 集成thymeleaf 此项目是在springsecurity-12-database-authorization-method 的基础上进行 复制springsecurity-12-database-authorization-method 并重命名为springsecurity-13-thymeleaf 15.1 添加thymeleaf依赖 | <groupId>org.springframewor…