controller里分页查询

@CrossOrigin

@RestController

@RequestMapping("/editor")

public class EditorController {

// @Autowired

// private EditorMapper editorMapper;

@Autowired

private EditorService editorService;

private Object log;

@PostMapping

public boolean save(@RequestBody Editor editor){

//新增或者更新

return editorService.saveEditor(editor);

}

//查询所有数据

@GetMapping

public List<Editor> findAll(){

return editorService.list();

}

@DeleteMapping("/{e_id}")

public boolean delete(@PathVariable Integer e_id){

return editorService.removeById(e_id);

}

//分页查询

//接口路径,/editor/page

//limit第一个参数 = (pageNum -1)*pageSize

//PageSize

// @GetMapping("/page")

// public Map<String,Object> findPage(@RequestParam Integer pageNum,@RequestParam Integer pageSize,@RequestParam String e_name){

// pageNum = (pageNum - 1) * pageSize;

// e_name = "%" + e_name +"%";

// List<Editor> data = editorMapper.selectPage(pageNum,pageSize,e_name);

// Integer total = editorMapper.selectTotal();

// Map<String,Object> res = new HashMap<>();

// res.put("data",data);

// res.put("total",total);

// return res;

//

// }

@GetMapping("/page")

public IPage<Editor> findPage(@RequestParam Integer pageNum,

@RequestParam Integer pageSize,

@RequestParam String e_name){

IPage<Editor> page=new Page<>(pageNum,pageSize);

QueryWrapper<Editor> queryWrapper= new QueryWrapper<>();

if(!"".equals(e_name)){

queryWrapper.like("e_name",e_name);

}

return editorService.page(page,queryWrapper);

}

mybatisplusconfig

@Configuration

@MapperScan("ckx_novel.ckx_novel.mapper")

public class MybatisPlusConfig {

/**

* 新的分页插件,一缓和二缓遵循mybatis的规则,需要设置 MybatisConfiguration#useDeprecatedExecutor = false 避免缓存出现问题(该属性会在旧插件移除后一同移除)

*/

@Bean

public MybatisPlusInterceptor mybatisPlusInterceptor() {

MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();

PaginationInnerInterceptor paginationInnerInterceptor = new PaginationInnerInterceptor();

paginationInnerInterceptor.setDbType(DbType.MYSQL);

paginationInnerInterceptor.setOverflow(true);

interceptor.addInnerInterceptor(paginationInnerInterceptor);

return interceptor;

}

}

}

实体类Editor

@Data

@TableName(value = "editor")

public class Editor {

@TableId(value = "e_id")

private Integer e_id;

private String e_name;

@JsonIgnore

private String password;

}

前端代码

<template>

<el-container style="min-height:100vh;">

<el-aside width="sideWidth + 'px'" style="background-color: rgb(238, 241, 246); height:100%">

<el-menu :default-openeds="['1', '3']" style="min-height: 100%;overflow-x: hidden"

background-color="rgb(48,65,86)"

text-color="#fff"

active-text-color="#ffd04b"

:collapse-transition="false"

:collapse="isCollapse">

<div style="height: 60px;line-height: 60px;text-align: center">

<img src="../assets/logo.png" alt="" style="width: 50px;position: relative;top:5px;margin-right: 6px">

<b style="color: white">编辑管理界面</b>

</div>

<el-submenu index="1">

<template slot="title"><i class="el-icon-message"></i><span>阅读管理</span></template>

<el-menu-item-group>

<el-menu-item index="1-1">加入书架</el-menu-item>

<el-menu-item index="1-2">继续阅读</el-menu-item>

</el-menu-item-group>

</el-submenu>

<el-submenu index="2">

<template slot="title"><i class="el-icon-menu"></i>

<span>论坛管理</span></template>

<el-menu-item-group>

<el-menu-item index="2-1">删除帖子</el-menu-item>

<el-menu-item index="2-2">屏蔽帖子</el-menu-item>

</el-menu-item-group>

</el-submenu>

<el-submenu index="3">

<template slot="title"><i class="el-icon-setting"></i>

<span>写作管理</span></template>

<el-menu-item index="3-3">添加书籍</el-menu-item>

<el-menu-item index="3-4-1">删除书籍</el-menu-item>

</el-submenu>

</el-menu>

</el-aside>

<el-container>

<el-header style=" font-size: 12px;border-bottom: 1px solid #cccccc;line-height: 60px;display: flex">

<div style="flex: 1;font-size: 18px">

<span :class="collapseBtnClass" style="cursor: pointer" @click="collapse"></span>

</div>

<el-dropdown style="width:70px;cursor: pointer">

<span >江楠</span>

<i class="el-icon-setting" style="margin-right: 15px"></i>

<el-dropdown-menu slot="dropdown">

<el-dropdown-item>个人信息</el-dropdown-item>

<el-dropdown-item>退出</el-dropdown-item>

</el-dropdown-menu>

</el-dropdown>

</el-header>

<el-main>

<div style="padding: 5px 0">

<el-input style="width: 150px" placeholder="请输入搜索名称" suffix-icon="el-icon-search" v-model="e_name"></el-input>

<el-button class="ml-5" type="primary" @click="load">搜索</el-button>

<el-button type="warning" @click="reset">重置</el-button>

</div>

<div style="padding: 10px 0">

<el-button type="primary">新增<i class="el-icon-circle-plus-outline"></i> </el-button>

<el-button type="danger">批量删除<i class="el-icon-remove-outline"></i> </el-button>

<el-button type="insert">导入<i class="el-icon-bottom"></i> </el-button>

<el-button type="upload">导出<i class="el-icon-top"></i> </el-button>

</div>

<el-table :data="tableData" border stripe :header-cell-class-name="headerBg">

<el-table-column prop="e_id" label="ID" width="80" ></el-table-column>

<el-table-column prop="e_name" label="编辑名" width="600" ></el-table-column>

<el-table-column label="操作" width="200" align="center">

<!-- eslint-disable-next-line -->

<template slot-scope="scope" >

<el-button type="success" >编辑<i class="el-icon-edit"></i> </el-button>

<el-button type="danger">删除<i class="el-icon-remove-outline"></i> </el-button>

</template>

</el-table-column>

</el-table>

<div style="padding: 10px 0">

<el-pagination

@size-change="handleSizeChange"

@current-change="handleCurrentChange"

:current-page="pageNum"

:page-sizes="[2, 4, 6, 8]"

:page-size="pageSize"

layout="total, sizes, prev, pager, next, jumper"

:total="total">

</el-pagination>

</div>

</el-main>

</el-container>

</el-container>

<!-- <div class="home">-->

<!-- <img alt="Vue logo" src="../assets/logo.png">-->

<!-- <HelloWorld msg="Welcome to Your Vue.js App"/>-->

<!-- </div>-->

</template>

<script>

// @ is an alias to /src

import HelloWorld from '@/components/HelloWorld.vue'

import request from "@/utils/request";

export default {

name: 'HomeView',

data() {

return {

tableData: [],

total:0,

pageNum:1,

pageSize:2,

e_name:"",

msg:"哈哈",

collapseBtnClass:'el-icon-s-fold',

isCollapse:false,

sideWidth:200,

logoTextShow:true,

headerBg:'headerBg'

}

},

created() {

this.load()

},

methods:{

collapse(){ //点击收缩按钮触发

this.isCollapse = !this.isCollapse

if(this.isCollapse){//收缩

this.sideWidth = 64

this.collapseBtnClass = 'el-icon-s-unfold'

this.logoTextShow= false

}else{//展开

this.sideWidth=200

this.collapseBtnClass ='el-icon-s-fold'

this.logoTextShow = true

}

},

load() {

request.get("/editor/page",{

params:{

pageNum:this.pageNum,

pageSize:this.pageSize,

e_name:this.e_name,

}

}).then(res => {

console.log(res)

this.tableData = res.records

this.total = res.total

})

},

reset(){

this.e_name= " "

this.load()

},

handleSizeChange(pageSize){

console.log(pageSize)

this.pageSize=pageSize

this.load()

},

handleCurrentChange(pageNum){

console.log(pageNum)

this.pageNum=pageNum

this.load()

}

},

}

</script>

求助,mybatisplus分页查询时records显示为null,但控制台可以打印查询的结果相关推荐

  1. node+Mysql,数据库时区显示正确,查询时却显示另一个时区

    问题: 1.node+Mysql,查看数据库时区显示正确,但查询时,显示的确是另一个时区的时间. 2.前端调用接口返回:startTime: "2020-03-04T17:53:55.000 ...

  2. MySQL工作笔记-建表时为Float型数据确定精度,查询时精度显示,多列之和查询

    目录 建表时设置精度 查询时设置精度 查询多列之和 建表时设置精度 首先是建表时为float类型设置精度: SQL代码如下: CREATE TABLE `testtable` (`id` int(11 ...

  3. Elasticsearch 查询时 判断不为null或不为空字符串

    最近遇到了查询es中某个字段为""或null,网上查了好多都是  去除null的查询 下面是我查询时解决方法, BoolQueryBuilder boolQueryBuilder ...

  4. mysql 查询商品列表 显示tag_javascript - MYSQL——怎么一个sql语句查询出用户和用户商品的列表啊...

    我现在都是先写一个sql查出所有用户数组,然后foreach循环这个数组拿id查他的所有商品数据,有没好点儿的方法 回复内容: 我现在都是先写一个sql查出所有用户数组,然后foreach循环这个数组 ...

  5. java sql查询空内容_返回null值而不是sql查询中的空集

    比方说,有两个表: select * from users; +-------+------+ | login | type | +-------+------+ | test1 | A | | te ...

  6. JAVA查询数据库并显示jsp_java servlet数据库查询并将数据显示到jsp页面

    需要的jar包:mysql-connector-java.jar build path只是个jar包的引用,部署的时候想不丢包最好还是手动拷贝到对应项目的lib文件下. 在try{}中定义的变量为局部 ...

  7. 查询时长下降10倍!网易有数 BI 物化视图设计要点与内部实践

    原文:查询时长下降10倍!网易有数 BI 物化视图设计要点与内部实践|数据库|sql|网易_新浪新闻 导读众所周知,BI 工具因其灵活的使用方式和便捷的结果展示,已成为生产运营和辅助管理决策的重要工具 ...

  8. 解决go数据表查询结构体对应字段null问题(sqlx converting NULL to string is unsupported)

    方法一:将结构体对应字段类型设为指针类型,一劳永逸,不用担心json序列化与反序列化问题 // User 用户结构体(对应mysql表) type User struct {Id int `db:&q ...

  9. Mybatisplus 分页查询时,禁止自动统计总数

    1.分页插件 使用 Mybatisplus 时 ,我们使用 PaginationInnerInterceptor 作为分页插件,它会帮助我们进行分页,查询总数. @Configuration @Map ...

最新文章

  1. 深度排序模型在淘宝直播的演进与应用
  2. python怎么导入视频-python中的导入如何使用,以及.和..相对导入的使用
  3. Python基础03 序列
  4. Eclipse上GIT插件EGIT使用手册之五_查看历史记录
  5. 关于iOS7里的JavaScriptCore framework
  6. [Math]添加了一个EulerProject标志
  7. 游戏用计算机配置表显卡,5000元电脑配置9代i5配GTX1660TI显卡配置清单(可装Win7)...
  8. TIOBE 6 月编程语言排行榜:Python 势不可挡,或在四年之内超越 Java、C
  9. Git基础教程(四)
  10. 请求参数完整性校验,解决流只能写一次的问题
  11. awk 输出到多个文件 多路输出
  12. 关于C语言的字符常量和符号常量
  13. Python打造一款属于自己的翻译词典
  14. chm文档打开后提示已取消网页导航
  15. 常见混沌系统—Lorenz模型
  16. matplotlib绘制鼠标的十字光标(内置方式)
  17. 计算机系统安全启动,安装Win11提示该电脑必须支持安全启动的解决方法
  18. Android 新建module时的ByteCode Level
  19. 论文阅读——FPGA based Accelerators of Deep Learning Networks for Learning and Classification:A Review
  20. 基于asp.net319一嗨租车汽车租赁系统

热门文章

  1. 多层神经网络 —— Sequential模型
  2. 分享113个HTML电子商务模板,总有一款适合您
  3. Class对象存储在Java堆中
  4. 美国佛罗里达州将允许无驾驶员辅助的自动驾驶汽车路测
  5. 最早应用计算机岩土三维模型技术,基于三维地质模型的岩土工程设计与可视分析...
  6. 【函数式编程】什么是函数式编程? C语言为何不是函数式语言?
  7. Rust vs. Go:为什么强强联合会更好
  8. 什么是cookie以及cookie的特性、优缺点
  9. vue + iview 设置滚动条样式
  10. JavaFX的MVC框架