/*An error occurred at line: 31 in the jsp file: /admin/staff-right.jsp
'<>' operator is not allowed for source level below 1.7*/
public class Pager<T> implements Serializable{
private int pageSize;//每页显示的记录数
private int currentPage;//当前页数
private int totalRecord;//一共多少记录
private int totalPage;//一共多少页
private List<T>dataList;//要显示的数据
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getCurrentPage() {
return currentPage;
}
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
public int getTotalRecord() {
return totalRecord;
}
public void setTotalRecord(int totalRecord) {
this.totalRecord = totalRecord;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public List<T> getDataList() {
return dataList;
}
public void setDataList(List<T> dataList) {
this.dataList = dataList;
}
public Pager(){
}
public Pager(int pageNum,int pageSize,List<T>sourceList){
Set(pageNum,pageSize,sourceList);
}
public void Set(int pageNum,int pageSize,List<T>sourceList){
if(sourceList==null){
return;
}
//获取总记录
this.totalRecord=sourceList.size();
//获取每页显示记录数
this.pageSize=pageSize;
//获取总页数
this.totalPage=this.totalRecord/this.pageSize;
if(this.totalRecord%this.pageSize!=0){
this.totalPage+=1;
}
//当前第几页数据
if(this.totalPage<pageNum){
this.currentPage=pageNum;
}else {
this.totalPage=pageNum;
}
//开始索引
int fromIndex=this.pageSize*(this.currentPage-1);
//结束索引
int toIndex;
if(this.currentPage*this.pageSize>this.totalRecord){
toIndex=this.totalRecord;
}else {
toIndex=this.currentPage*this.pageSize;
}
this.dataList=sourceList.subList(fromIndex, toIndex);
}
}
//List<Employee> employees = EmployeeController.findAllEmployees();
//Pager<Employee> pager=new Pager<>(currentPage,pageSize,employees);
//Pager<Employee> pager=new Pager<Employee>(currentPage,pageSize,employees);
//两种都有错 错误提示:An error occurred at line: 31 in the jsp file: /admin/staff-right.jsp
'<>' operator is not allowed for source level below 1.7
//提示有错无聊的缄默
HansonQ
相关分类