zoukankan      html  css  js  c++  java
  • pageHelper分页

    package com.example.controller;

    import com.example.entity.User;
    import com.example.service.UserService;
    import com.github.pagehelper.PageHelper;
    import com.github.pagehelper.PageInfo;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.RequestMapping;
    import org.springframework.web.bind.annotation.RequestMethod;
    import org.springframework.web.bind.annotation.RequestParam;
    import org.springframework.web.bind.annotation.ResponseBody;

    import java.util.List;

    @Controller
    public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/all")
    @ResponseBody
    public PageInfo<User> all(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "2") int pageSize){
    /**
    * pagehelper分页有法
    * 该函数返回PageInfo<User>对象
    */
    // 第一步 确定页码,包括当前与,以前一页显示多少条
    PageHelper.startPage(page,pageSize);
    // 第二步:查询构建结果集
    List<User> users = userService.showAllUser();
    // 第三步:用PageInfo来返回结果集,里面包括数据,以及分页的详细情误
    PageInfo<User> userPageInfo = new PageInfo<>(users);
    return userPageInfo;
    }

    @RequestMapping("/del")
    public String delUser(String email){
    int i = userService.deleteUser(email);
    System.out.println("删除了:"+i+"条数据");
    // 重定向
    return "redirect:/all";
    }


    }
  • 相关阅读:
    Python-快速入门
    Python-面向对象编程
    python-模块
    .net mvc onexception capture; redirectresult;
    a c lang in linux
    上海哪里有学陈氏太极拳?
    【Origin】 叹文
    【Origin】 碑铭
    【Origin】 偶题 之 抒意
    【Origin】答友朋关切书
  • 原文地址:https://www.cnblogs.com/leigepython/p/10112737.html
Copyright © 2011-2022 走看看