/*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
//提示有错
2 回答
已采纳
无聊的缄默
TA贡献4条经验 获得超2个赞
你发的第100代码 Pager<Employee> pager = new Pager<>(currentPage, pageSize, employees);
这种写法只有在jdk1.7以上的版本才支持 后面的尖括号中省略类型
jdk1.5 1.6的版本 后方的尖括号中 也要写 Employee 要和前面的 一直 才行
HansonQ
TA贡献223条经验 获得超56个赞
你看下你的项目环境和编译环境是不是都是1.7.
一般都是eclipse的编译环境与项目的要求不对应造成的,这个错误一般是导入别的项目才出现的。
右键项目--属性--勾选Enable project specific settings--Compiler compliance level--选择1.7--OK
添加回答
举报
0/150
提交
取消