当前位置:网站首页>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
边栏推荐
- 山大网安靶场实验平台项目—个人记录(四)
- Encyclopedia of professional terms and abbreviations in communication engineering
- 精简CUDA教程——CUDA Driver API
- filebeat、logstash配置安装
- Possible root causes include a too low setting for -Xss and illegal cyclic inheritance dependencies
- Kubernetes entry to mastery - bare metal loadbalance 80 443 port exposure precautions
- MySQL数据库 - 单表查询(三)
- An algorithm problem was encountered during the interview_ Find the mirrored word pairs in the dictionary
- Is meituan, a profit-making company with zero foundation, hungry? Coupon CPS applet (with source code)
- Shanda Wangan shooting range experimental platform project - personal record (V)
猜你喜欢
2021-2022-2 ACM集训队每周程序设计竞赛(8)题解
[report] Microsoft: application of deep learning methods in speech enhancement
[报告] Microsoft :Application of deep learning methods in speech enhancement
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
@MapperScan与@Mapper
基于pytorch搭建GoogleNet神经网络用于花类识别
Common SQL commands
RuntimeError: Providing a bool or integral fill value without setting the optional `dtype` or `out`
【webrtc】Add x264 encoder for CEF/Chromium
ESP8266-入门第一篇
随机推荐
深度学习环境搭建步骤—gpu
The most detailed network counting experiment in history (2) -- rip experiment of layer 3 switch
What is a message queue
php参考手册String(7.2千字)
Inject Autowired fields into ordinary beans
Using oes texture + glsurfaceview + JNI to realize player picture processing based on OpenGL es
Why is the hexadecimal printf output of C language sometimes with 0xff and sometimes not
点云数据集常用处理
DevOps集成-Jenkins 服务的环境变量和构建工具 Tools
HTTP cache - HTTP authoritative guide Chapter VII
MySQL数据库 - 单表查询(三)
The flyer realizes page Jump through routing routes
ArcMap connecting ArcGIS Server
Pdf reference learning notes
Easy mock local deployment (you need to experience three times in a crowded time. Li Zao will do the same as me. Love is like a festival mock)
Intuitive understanding of the essence of two-dimensional rotation
Machine learning catalog
C语言的十六进制printf为何输出有时候输出带0xFF有时没有
Codeforces Round #783 (Div. 2) D题解
Garbage collector and memory allocation strategy