MyBatis实现分页与ajax笔记(小白向)
发布日期:2021-05-10 06:21:01 浏览次数:15 分类:精选文章

本文共 2731 字,大约阅读时间需要 9 分钟。

MyBatis���������������������PageHelper���������

Step-by-Step Guide

1. ������Maven������

������������������������PageHelper������������������������������������������������������������

com.github.pagehelper
pagehelper
4.0.0

2. ������PageHelper������

������������MyBatis������������������������������������������

mysql
true

3. Service������������������PageHelper

���Service���������������������������

@Override
public PageInfo getPageInfo(String keyword, Integer pageNum, Integer pageSize) {
PageHelper.startPage(pageNum, pageSize);
List
listOrder = orderDao.selectOrderByKeyword(keyword);
return new PageInfo<>(listOrder);
}

4. Controller������������

���Controller������������������������

@ResponseBody
@RequestMapping("/getPageInfo02")
public PageInfo getPageInfo02(
@RequestParam(defaultValue = "") String keyword,
@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize) {
PageInfo pageInfo = orderService.getPageInfo(keyword, pageNum, pageSize);
return pageInfo;
}

5. ������AJAX������������������

���������������JavaScript���������

$(function() {
$('#btn1').click(function() {
var array = [5, 8, 12]; // ������������������
$.ajax({
url: 'send/array.html',
type: 'POST',
data: JSON.stringify(array),
contentType: 'application/json;charset=utf-8',
dataType: 'text',
success: function(data) {
alert(data);
},
error: function(error) {
alert(error);
}
});
});
});

AJAX������������

������

AJAX���������JavaScript���XML���������������������������������������������������������������������������������������������������������������������������

������������

  • ������������
  • ������������
  • ������������������������
  • ������

    ���������������AJAX���������������

    $(function() {
    $.ajax({
    url: 'http://localhost:8080/getPageInfo02',
    type: 'GET',
    dataType: 'json',
    success: function(data) {
    console.log(data);
    }
    });
    });

    ������������

    • ���������������������������������Phone���������������������������������
    • AJAX���������������������������������������������������
    • ���������������������������������������������

    ������������������������������������������MyBatis������������������������AJAX���������������������������������������������������������������������

    上一篇:关于linux上的防火墙问题。(Redis,Tomcat无法访问等问题)
    下一篇:MySQL基础常用笔记(概念,常用关键字,语句。示例代码等)

    发表评论

    最新留言

    做的很好,不错不错
    [***.243.131.199]2025年04月09日 14时50分37秒