当前位置:网站首页>Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (VII)
Project training of Software College of Shandong University - Innovation Training - network security shooting range experimental platform (VII)
2022-04-23 19:40:00 【Scrambled eggs with tomatoes without eggs!】
Catalog
Two 、Vue The paging component ——el-pagination
3、 ... and 、mybatis Pagination ——selectPage
Preface : This blog mainly explains the paging function in the forum part
One 、Forum Paging function
In the forum function , Users will post more and more comments , As a result, more and more front-end interfaces will be displayed , in other words card More and more .
For ease of reading , Improve the speed of database query and page rendering , I used paging to render .
The interface is as follows :
At present, four are displayed on each page , Now total 10 strip , So there are three pages .

Two 、Vue The paging component ——el-pagination
The paging component is <el-pagination/>, Usage is as follows :
<el-pagination
v-model:currentPage="currentPage"
:page-size="pageSize"
:disabled="disabled"
:background="background"
layout="total, prev, pager, next"
:total="totalpage"
@size-change="handleSizeChange"
@current-change="load"
style="padding-top: 20px"
/>
The initial bound data is :
return {
formatTooltip,
goto_write,
search:'',
currentPage:1,
pageSize:4,
totalpage:0,
forumlist:[],
};
The rendering method is :
load(){
request.get("/forum/page",{
params:{
pageNum:this.currentPage,
pageSize:this.pageSize,
search:this.search
}
}).then(res =>{
this.forumlist=res.data.records
this.totalpage=res.data.total
})
},
The rendering method will <el-card> What is needed in forumlist Data binding
<el-space direction="vertical" style="text-align: left">
<el-card v-for="(forum,i) in forumlist" :key="i" class="box-card" style="width: 1200px;background-color: #99a9bf" shadow="hover">
<template #header>
<div class="card-header">
<span style="font-weight:bold">{
{ forum.title }}</span>
</div>
</template>
<div class="text item">
{
{ forum.content }}
</div>
<div class="text item" style="margin-top: 20px">
{
{ forum.username }}
</div>
<div class="text item" style="text-align: right">
{
{ forum.time }}
</div>
</el-card>
</el-space>
3、 ... and 、mybatis Pagination ——selectPage
In the writing of back-end code , First, write the entity class Forum.java
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
@Data
@TableName("forum")
public class Forum {
@TableId(type = IdType.AUTO)
private Integer forumid;
private String title;
private String content;
private Integer username;
private String time;
private Integer state;
}
ForumController.java
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sducsrp.csrp.common.Result;
import com.sducsrp.csrp.entity.Forum;
import com.sducsrp.csrp.mapper.ForumMapper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
@RestController
@RequestMapping("/forum")
public class ForumController {
@Resource
ForumMapper forumMapper;
@GetMapping("/page")
public Result findpage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "") String search){
Page<Forum> forumPage=forumMapper.selectPage(new Page<>(pageNum,pageSize), Wrappers.<Forum>lambdaQuery().like(Forum::getForumid,search));
return Result.success(forumPage);
}
}
among , The most important code is :
@GetMapping("/page")
public Result findpage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@RequestParam(defaultValue = "") String search){
Page<Forum> forumPage=forumMapper.selectPage(new Page<>(pageNum,pageSize), Wrappers.<Forum>lambdaQuery().like(Forum::getForumid,search));
return Result.success(forumPage);
}
This is a mybatis Paging function of , Both query function
Parameters respectively ask the number of query pages 、 Page size 、 And the query content .
版权声明
本文为[Scrambled eggs with tomatoes without eggs!]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231929365664.html
边栏推荐
- Executor、ExecutorService、Executors、ThreadPoolExecutor、Future、Runnable、Callable
- 山大网安靶场实验平台项目—个人记录(四)
- C6748 软件仿真和硬件测试 ---附详细FFT硬件测量时间
- A brief explanation of golang's keyword "competence"
- Kubernetes入门到精通-在 Kubernetes 上安装 OpenELB
- NiO related Basics
- JS to get the local IP address
- 深度分析数据恢复原理——那些数据可以恢复那些不可以数据恢复软件
- Zero cost, zero foundation, build profitable film and television applet
- The difference between underline and dot of golang import package
猜你喜欢

Shanda Wangan shooting range experimental platform project - personal record (V)

Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)

Intuitive understanding of the essence of two-dimensional rotation

Decompile and get the source code of any wechat applet - just read this (latest)

精简CUDA教程——CUDA Driver API

C6748 software simulation and hardware test - with detailed FFT hardware measurement time

Physical meaning of FFT: 1024 point FFT is 1024 real numbers. The actual input to FFT is 1024 complex numbers (imaginary part is 0), and the output is also 1024 complex numbers. The effective data is

5 minutes to achieve wechat cloud applet payment function (including source code)

@MapperScan与@Mapper

Build intelligent garbage classification applet based on Zero
随机推荐
Efficient serial port cyclic buffer receiving processing idea and code 2
Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not
Main differences between go and PHP
Thoughts on the optimization of examination papers in the examination system
How to uninstall easyton
JVM的类加载过程
深度学习环境搭建步骤—gpu
基于pytorch搭建GoogleNet神经网络用于花类识别
C6748 软件仿真和硬件测试 ---附详细FFT硬件测量时间
Speex维纳滤波与超几何分布的改写
Go three ways to copy files
对普通bean进行Autowired字段注入
An idea of rendering pipeline based on FBO
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
MySQL syntax collation (3)
数据库查询 - 选课系统
[webrtc] add x264 encoder for CEF / Chromium
Audio editing generation software
uIP1. 0 actively sent problem understanding
Go modules daily use