黑马旅游网-学习笔记Part07

YangeIT大约 6 分钟旅游项目Mysql

黑马旅游网-学习笔记Part07

今日目标

  • 旅游路线分页展示 🍐 ✏️
  • 旅游线路的详情展示 ✏️

知识储备

  1. 了解分页查询的作用(可以点击这open in new window)

1. 旅游路线分页展示

旅游路线分页展示

需求
需求

代码操作

  1. 准备封装类、分页插件、检查uri编码
  2. 控制层的Servlet
  3. 业务层的Service
  4. 持久层的Mapper 流程

点击查看文件示意图open in new window 👈

1.domain 包下的实体类 👇

public class PageBean<T> {

    private int totalCount;//总记录数
    private int totalPage;//总页数
    private int currentPage;//当前页码
    private int pageSize;//每页显示的条数

    private List<T> list;//每页显示的数据集合

    // 补全getset方法
}

2.在pom.xml下导入PageHelper插件 进行物理分页👇

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.1.2</version>
</dependency>

3.在mybatis-config.xml下配置插件 👇 image

<!--分页插件-->
<plugins>
    <plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
</plugins>

4.检查pom.xml下的tomcat插件是否配置了uri编码为utf-8 image

2. 旅游线路的详情展示

旅游线路的详情展示

image
image

代码操作

  1. 封装实体类,对应的表格
  2. 控制层的Servlet
  3. 业务层的Service
  4. 持久层的Mapper 流程
实体类对应表结构
实体类对应表结构