• J2EE--通用分页


    一、Junit4运用

    首先我们第一步要在运行测试的类同包的情况下建立,如我这里在BookDao里面建立一个Junit4,选择包右键或者在BookDao按住Ctrl+n
    ,搜索Junit。
    在这里插入图片描述
    选择Junit Text Case,点击Next,最上面选择New JUnit 4 text,下面的setUp() tearDown()看自己需求选,点击ok就可以建立一个测试类
    在这里插入图片描述

    优点:可以针对单个方法进行测试,相较于main方法而言,测试耦合性降低了

    package com.xlb.dao;
    
    import static org.junit.Assert.*;
    import org.junit.After;
    import org.junit.Before;
    import org.junit.Test;
    /**
     * 那个针对单个方法进行测试 
     * 相较于main而言,测试耦合性降低了
     * @author 波哥
     *
     * 2022年6月21日 下午6:47:33
     */
    public class BookDaoTest {
    
    	/**
    	 * 
    	 * @throws Exception
    	 */
    	@Before
    	public void setUp() throws Exception {
    		System.out.println("被测试方法执行之前调用");
    	}
    
    	@After
    	public void tearDown() throws Exception {
    		System.out.println("被测试方法执行之后被调用");
    	}
    
    	@Test
    	public void testList() throws Throwable {
    		//写测试的代码
    	}
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35

    二、底层代码搭建

    这边我以我的MySql数据库为主,我们首先要导入我们所用的上的依赖(这边我导入了许多多余的依赖因为后期可能会对博客进行修改和代码修改)
    在这里插入图片描述
    然后建立工具类包,导入需要的工具类
    DBAccess.java数据库工具类

    package com.xlb.util;
    
    import java.io.InputStream;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.Properties;
    
    /**
     * 
     * @author 波哥
     *
     * 2022年6月22日 上午9:18:49
     */
    public class DBAccess {
    	private static String driver;
    	private static String url;
    	private static String user;
    	private static String password;
    
    	static {// 静态块执行一次,加载 驱动一次
    		try {
    			InputStream is = DBAccess.class
    					.getResourceAsStream("config.properties");
    
    			Properties properties = new Properties();
    			properties.load(is);
    
    			driver = properties.getProperty("driver");
    			url = properties.getProperty("url");
    			user = properties.getProperty("user");
    			password = properties.getProperty("pwd");
    
    			Class.forName(driver);
    		} catch (Exception e) {
    			e.printStackTrace();
    			throw new RuntimeException(e);
    		}
    	}
    
    	/**
    	 * 获得数据连接对象
    	 * 
    	 * @return
    	 */
    	public static Connection getConnection() {
    		try {
    			Connection conn = DriverManager.getConnection(url, user, password);
    			return conn;
    		} catch (SQLException e) {
    			e.printStackTrace();
    			throw new RuntimeException(e);
    		}
    	}
    
    	public static void close(ResultSet rs) {
    		if (null != rs) {
    			try {
    				rs.close();
    			} catch (SQLException e) {
    				e.printStackTrace();
    				throw new RuntimeException(e);
    			}
    		}
    	}
    
    	public static void close(Statement stmt) {
    		if (null != stmt) {
    			try {
    				stmt.close();
    			} catch (SQLException e) {
    				e.printStackTrace();
    				throw new RuntimeException(e);
    			}
    		}
    	}
    
    	public static void close(Connection conn) {
    		if (null != conn) {
    			try {
    				conn.close();
    			} catch (SQLException e) {
    				e.printStackTrace();
    				throw new RuntimeException(e);
    			}
    		}
    	}
    
    	public static void close(Connection conn, Statement stmt, ResultSet rs) {
    		close(rs);
    		close(stmt);
    		close(conn);
    	}
    
    	public static boolean isOracle() {
    		return "oracle.jdbc.driver.OracleDriver".equals(driver);
    	}
    
    	public static boolean isSQLServer() {
    		return "com.microsoft.sqlserver.jdbc.SQLServerDriver".equals(driver);
    	}
    	
    	public static boolean isMysql() {
    		return "com.mysql.cj.jdbc.Driver".equals(driver);
    	}
    
    	public static void main(String[] args) {
    		Connection conn = DBAccess.getConnection();
    		System.out.println(conn);
    		DBAccess.close(conn);
    		System.out.println("isOracle:" + isOracle());
    		System.out.println("isSQLServer:" + isSQLServer());
    		System.out.println("isMysql:" + isMysql());
    		System.out.println("数据库连接(关闭)成功");
    	}
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119

    过滤器处理乱码方式类EncodingFiter.java

    package com.xlb.util;
    
    import java.io.IOException;
    import java.util.Iterator;
    import java.util.Map;
    import java.util.Set;
    
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    /**
     * 中文乱码处理
     * 
     */
    public class EncodingFiter implements Filter {
    
    	private String encoding = "UTF-8";// 默认字符集
    
    	public EncodingFiter() {
    		super();
    	}
    
    	public void destroy() {
    	}
    
    	public void doFilter(ServletRequest request, ServletResponse response,
    			FilterChain chain) throws IOException, ServletException {
    		HttpServletRequest req = (HttpServletRequest) request;
    		HttpServletResponse res = (HttpServletResponse) response;
    
    		// 中文处理必须放到 chain.doFilter(request, response)方法前面
    		res.setContentType("text/html;charset=" + this.encoding);
    		if (req.getMethod().equalsIgnoreCase("post")) {
    			req.setCharacterEncoding(this.encoding);
    		} else {
    			Map map = req.getParameterMap();// 保存所有参数名=参数值(数组)的Map集合
    			Set set = map.keySet();// 取出所有参数名
    			Iterator it = set.iterator();
    			while (it.hasNext()) {
    				String name = (String) it.next();
    				String[] values = (String[]) map.get(name);// 取出参数值[注:参数值为一个数组]
    				for (int i = 0; i < values.length; i++) {
    					values[i] = new String(values[i].getBytes("ISO-8859-1"),
    							this.encoding);
    				}
    			}
    		}
    
    		chain.doFilter(request, response);
    	}
    
    	public void init(FilterConfig filterConfig) throws ServletException {
    		String s = filterConfig.getInitParameter("encoding");// 读取web.xml文件中配置的字符集
    		if (null != s && !s.trim().equals("")) {
    			this.encoding = s.trim();
    		}
    	}
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65

    通用分页类PageBean.java

    package com.xlb.util;
    
    /**
     * 分页工具类
     */
    public class PageBean {
    
    	private int page = 1;// 页码
    
    	private int rows = 10;// 页大小
    
    	private int total = 0;// 总记录数
    
    	private boolean pagination = true;// 是否分页
    
    	public PageBean() {
    		super();
    	}
    
    	public int getPage() {
    		return page;
    	}
    
    	public void setPage(int page) {
    		this.page = page;
    	}
    
    	public int getRows() {
    		return rows;
    	}
    
    	public void setRows(int rows) {
    		this.rows = rows;
    	}
    
    	public int getTotal() {
    		return total;
    	}
    
    	public void setTotal(int total) {
    		this.total = total;
    	}
    
    	public void setTotal(String total) {
    		this.total = Integer.parseInt(total);
    	}
    
    	public boolean isPagination() {
    		return pagination;
    	}
    
    	public void setPagination(boolean pagination) {
    		this.pagination = pagination;
    	}
    
    	/**
    	 * 获得起始记录的下标
    	 * 
    	 * @return
    	 */
    	public int getStartIndex() {
    		return (this.page - 1) * this.rows;
    	}
    
    	@Override
    	public String toString() {
    		return "PageBean [page=" + page + ", rows=" + rows + ", total=" + total + ", pagination=" + pagination + "]";
    	}
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71

    判空类StringUtils.java

    package com.xlb.util;
    
    /**
     * 判空类
     * @author 波哥
     *
     * 2022年6月21日 下午6:21:53
     */
    public class StringUtils {
    	// 私有的构造方法,保护此类不能在外部实例化
    	private StringUtils() {
    	}
    
    	/**
    	 * 如果字符串等于null或去空格后等于"",则返回true,否则返回false
    	 * @param s
    	 * @return
    	 */
    	public static boolean isBlank(String s) {
    		boolean b = false;
    		if (null == s || s.trim().equals("")) {
    			b = true;
    		}
    		return b;
    	}
    	
    	/**
    	 * 如果字符串不等于null或去空格后不等于"",则返回true,否则返回false
    	 * 
    	 * @param s
    	 * @return
    	 */
    	public static boolean isNotBlank(String s) {
    		return !isBlank(s);
    	}
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38

    数据库连接文件config.properties

    #oracle9i
    #driver=oracle.jdbc.driver.OracleDriver
    #url=jdbc:oracle:thin:@localhost:1521:orcl
    #user=scott
    #pwd=123
    
    
    #sql2005
    #driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
    #url=jdbc:sqlserver://localhost:1433;DatabaseName=test1
    #user=sa
    #pwd=123
    
    
    #sql2000
    #driver=com.microsoft.jdbc.sqlserver.SQLServerDriver
    #url=jdbc:microsoft:sqlserver://localhost:1433;databaseName=unit6DB
    #user=sa
    #pwd=888888
    
    
    #mysql
    driver=com.mysql.jdbc.Driver
    url=jdbc:mysql://localhost:3306/库名?useUnicode=true&characterEncoding=UTF-8&useSSL=false
    user=数据库账号
    pwd=数据库密码
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26

    书籍实体类Book.java

    package com.xlb.entity;
    
    public class Book {
    	
    	private int bid;
    	private String bname;
    	private float price;
    
    	@Override
    	public String toString() {
    		return "Book [bid=" + bid + ", bname=" + bname + ", price=" + price + "]";
    	}
    
    	public int getBid() {
    		return bid;
    	}
    
    	public void setBid(int bid) {
    		this.bid = bid;
    	}
    
    	public String getBname() {
    		return bname;
    	}
    
    	public void setBname(String bname) {
    		this.bname = bname;
    	}
    
    	public float getPrice() {
    		return price;
    	}
    
    	public void setPrice(float price) {
    		this.price = price;
    	}
    
    	public Book(int bid, String bname, float price) {
    		super();
    		this.bid = bid;
    		this.bname = bname;
    		this.price = price;
    	}
    	
    	public Book() {
    		// TODO Auto-generated constructor stub
    	}
    
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49

    BookDao.java,在里面搭建带条件的查询方法

    package com.xlb.dao;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.List;
    
    import com.xlb.entity.Book;
    import com.xlb.util.BeseDao;
    import com.xlb.util.DBAccess;
    import com.xlb.util.PageBean;
    import com.xlb.util.StringUtils;
    
    *
     * 书籍的方法类
     * @author 波哥
     *
     * 2022621日 下午6:32:12
     */
    public class BookDao extends BeseDao<Book>{
    	
    	
    	public List<Book> list(Book book,PageBean pageBean) throws Exception{
    		List<Book> list=new ArrayList<Book>();
    		/**
    		 * 1、拿到数据库连接
    		 * 2、拿到Preparestatement
    		 * 3、执行SQL语句
    		 */
    		Connection con=DBAccess.getConnection();//重复代码1
    		String sql="select * from t_mvc_book where 1=1 ";
    		String bname=book.getBname();
    		if(StringUtils.isNotBlank(bname)) {
    			sql+="and bname like '%"+bname+"%' ";
    		}
    		int bid=book.getBid();
    		if(bid!=0) {
    			sql+=" and bid="+bid;
    		}
    		PreparedStatement ps = con.prepareStatement(sql);//重复代码2
    		//处理结果集
    		ResultSet rs=ps.executeQuery();//重复代码3
    		//循环遍历
    		while(rs.next()) {
    			list.add(new Book(rs.getInt("bid"), rs.getString(2),rs.getFloat("price")));
    		}
    		return list;
    	}
    	
    	
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53

    然后我们在测试类测试一下
    在这里插入图片描述
    但是现在可以发现我们的重复代码还是有点多的,那么现在优化重复代码
    我们建立一个泛类,来优化代码BeseDao.java

    package com.xlb.util;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.util.ArrayList;
    import java.util.List;
    
    import com.xlb.entity.Book;
    
    /**
     * T代表的是实体类,可以是Book/User/Goods。。。
     * 泛型方法类(公有方法类)
     * @author 波哥
     *
     * 2022年6月21日 下午6:49:41
     */
    public class BeseDao<T> {
    	
    	//第一个版本
    	public List<T> list(String sql,PageBean pageBean,CallBack<T> callBack) throws Exception{
    		//拿到总记录数->得到总页数
    		
    		/**
    		 * 1、拿到数据库连接
    		 * 2、拿到Preparestatement
    		 * 3、执行SQL语句
    		 */
    		Connection con=DBAccess.getConnection();//重复代码1
    		PreparedStatement ps = con.prepareStatement(sql);//重复代码2
    		//处理结果集
    		ResultSet rs=ps.executeQuery();//重复代码3
    		//循环遍历
    //		while(rs.next()) {
    //			list.add(new Book(rs.getInt("bid"), rs.getString(2),rs.getFloat("price")));
    //		}
    		//查询不同的表,必然要处理不同的结果集
    		//callBack接口是调用方来实现
    		return callBack.foreach(rs);
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40

    这里需要实现一个接口,以便于处理各种调用事物
    CallBack.java

    package com.xlb.util;
    
    import java.sql.ResultSet;
    import java.util.List;
    
    /**
     * 回调函数接口类的作用?
     * 谁调用谁处理
     * @author 波哥
     *
     * 2022年6月21日 下午6:52:49
     */
    public interface CallBack<T> {
    
    	List<T> foreach(ResultSet rs);
    
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    BookDao方法代码就转变为

    public List<Book> list2(Book book,PageBean pageBean) throws Exception{
    		String sql="select * from t_mvc_book where 1=1 ";
    		String bname=book.getBname();
    		if(StringUtils.isNotBlank(bname)) {
    			sql+="and bname like '%"+bname+"%' ";
    		}
    		int bid=book.getBid();
    		if(bid!=0) {
    			sql+=" and bid="+bid;
    		}
    		return super.list(sql, null, rs ->{
    			List<Book> ls=new ArrayList<>();
    			try {
    				while(rs.next()) {
    					ls.add(new Book(rs.getInt("bid"), rs.getString(2),rs.getFloat("price")));
    				}
    			} catch (Exception e) {
    				e.printStackTrace();
    			}
    			return ls;
    		});
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22

    运行结果(说明可以用)
    在这里插入图片描述

    三、通用分页

    因为我们需要通用分页,那么sql语句就要加入一个分页条件,而且我们分页还要获取到这个条件查询到的结果行数,如果对页码进行计算,这边我们PageBean.java里面已经全部更改完
    那么通用泛类的代码如下(BeseDao包):

    public List<T> list(String sql,PageBean pageBean,CallBack<T> callBack) throws Exception{
    		/**
    		 * 1、拿到数据库连接
    		 * 2、拿到Preparestatement
    		 * 3、执行SQL语句
    		 */
    		Connection con=null;//重复代码1
    		PreparedStatement ps = null;//重复代码2
    		//处理结果集
    		ResultSet rs=null;//重复代码3
    		if(pageBean !=null && pageBean.isPagination()) {
    			String countSQL=getCountSQL(sql);
    			con=DBAccess.getConnection();//重复代码1
    			ps = con.prepareStatement(countSQL);//重复代码2
    			//处理结果集
    			rs=ps.executeQuery();//重复代码3
    			//把总记录数存进去
    			if(rs.next()) {
    				//当前实体列包含了总记录数
    				pageBean.setTotal(rs.getString("n"));
    			}
    			String pageSQL=getPageSQL(sql,pageBean);
    			con=DBAccess.getConnection();//重复代码1
    			ps = con.prepareStatement(pageSQL);//重复代码2
    			//处理结果集
    			rs=ps.executeQuery();//重复代码3
    		}
    		else {//不分页
    			con=DBAccess.getConnection();//重复代码1
    			ps = con.prepareStatement(sql);//重复代码2
    			//处理结果集
    			rs=ps.executeQuery();//重复代码3
    		}
    		
    		return callBack.foreach(rs);
    	}
    
    	
    
    	/**
    	 * 拼装第N页的数据的SQL
    	 * @param sql 
    	 * @param pageBean
    	 * @return
    	 */
    	private String getPageSQL(String sql, PageBean pageBean) {
    		// TODO Auto-generated method stub
    		return sql + " limit " + pageBean.getStartIndex() + "," + pageBean.getRows() ;
    	}
    
    
    	/**
    	 * 拼装符合条件总记录数的SQL
    	 * @param sql
    	 * @return
    	 */
    	private String getCountSQL(String sql) {
    		return "select count(1) as n from ("+sql+") t";
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59

    我们BookDao前面没有传入PageBean类,所有就一直是查询全部,这边我们把PageBean加上
    在这里插入图片描述
    最后我们去测试类测试
    查询第二页,书名带圣墟的数据

    @Test
    	public void testList2() throws Exception{
    		Book b = new Book();
    		b.setBname("圣墟");
    		PageBean pageBean = new PageBean();
    		pageBean.setPage(2);
    		List<Book> list = new BookDao().list2(b,pageBean);
    		for (Book book : list) {
    			System.out.println(book);
    		}
    	}
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    结果
    在这里插入图片描述

  • 相关阅读:
    用Python实现链式调用
    手写数字识别——算法
    PMP考试敏捷占比有多少?解疑
    MySQL的视图
    YYDS!一行Python代码即可实现数据可视化大屏
    Postman脚本炼金术:高级数据处理的秘籍
    LeetCode 面试题 16.02. 单词频率
    c++模板
    fiddler抓包番外————了解工具栏
    【PDF密码】PDF文件打开之后不能打印,怎么解决?
  • 原文地址:https://blog.csdn.net/qq_63531917/article/details/125402468