1、实体类
package cn.jpp.entity;
import cn.jpp.util.Page;
/**
* Created by 景佩佩 on 2017/1/16.
*/
public class UserInfo extends Page {
private String id;
private String username;
private String password;
private Integer age;
private String sex;
private String role;
private String email;
private String account;
private Integer sign;
private String authority;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getAccount() {
return account;
}
public void setAccount(String account) {
this.account = account;
}
public Integer getSign() {
return sign;
}
public void setSign(Integer sign) {
this.sign = sign;
}
public String getAuthority() {
return authority;
}
public void setAuthority(String authority) {
this.authority = authority;
}
public UserInfo() {
}
public UserInfo(String id, String username, String password, Integer age, String sex, String role, String email, String account, Integer sign, String authority) {
this.id = id;
this.username = username;
this.password = password;
this.age = age;
this.sex = sex;
this.role = role;
this.email = email;
this.account = account;
this.sign = sign;
this.authority = authority;
}
}
package cn.jpp.util;
public class Page {
private int pageNumber; //每页的条数
private int offset; //数据库查询索引
public int getPageNumber() {
return pageNumber;
}
public void setPageNumber(int pageNumber) {
this.pageNumber = pageNumber;
}
public int getOffset() {
return offset;
}
public void setOffset(int offset) {
this.offset = offset;
}
}
package cn.jpp.util;
import java.util.ArrayList;
import java.util.List;
/**
* 返回数据实体类
* @param <T>
*/
public class ReturnData <T>{
//数据集合
private List<T> rows = new ArrayList<T>();
//数据总条数
private int total;
public List<T> getRows() {
return rows;
}
public void setRows(List<T> rows) {
this.rows = rows;
}
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
}
2、后端查询数据
@RequestMapping(value = "/userList", method = RequestMethod.GET)
@ResponseBody
public Object showUserInfo(HttpServletRequest request, HttpSession session,UserInfo userInfo){
ReturnData<UserInfo> peopleData = new ReturnData<UserInfo>();
//得到总页数
int totle = iUserInfoService.getTatlo();
peopleData.setTotal(totle);
userInfo.setPageNumber(1);
userInfo.setOffset(10);
//得到user数据对象
List<UserInfo> plist = iUserInfoService.selectAllUser1(userInfo);
peopleData.setRows(plist);
return peopleData;
}
3、前端页面
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/