java ssm 分页_ssm框架整合入门系列——查询-分页显示数据

该博客介绍了如何在Java SSM框架中进行分页查询数据,详细讲解了使用PageHelper插件的过程,包括在EmployeeController和EmployeeService中的配置,以及测试和页面展示。同时,提供了MvcTest的单元测试用例,展示了查询结果的验证。
摘要由CSDN通过智能技术生成

ssm框架整合入门系列——查询-分页显示数据(pageHelper的使用)

查询也就是显示操作,在该项目下具体表现为:

访问index.jsp页面

index.jsp页面发送出查询员工列表请求

EmployeeController 来接受请求,查出员工数据

来到list.jsp页面进行展示

修改index.jsp为:

String path = request.getContextPath();

String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>

在com.liantao.crud.controller下新建EmployeeController.java

package com.liantao.crud.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestParam;

import com.github.pagehelper.PageHelper;

import com.github.pagehelper.PageInfo;

import com.liantao.crud.bean.Employee;

import com.liantao.crud.service.EmployeeService;

/**

* 处理员工的crud请求

* @author liantao.me

*

*/

@Controller

public class EmployeeController {

@Autowired

EmployeeService employeeService;

/*

* 查询员工数据(分页查询)

* @return

*/

@RequestMapping("/emps")

public String getEmps(@RequestParam(value="pn",defaultValue="1")Integer pn,Model model){

//引入PageHelper分页插件

//查询之前需要调用,,传入页码,以及每页的大小

PageHelper.st

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值