/*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;//每頁顯示的記錄數(shù)
????
????private?int?currentPage;//當(dāng)前頁數(shù)
????
????private?int?totalRecord;//一共多少記錄
????
????private?int?totalPage;//一共多少頁
????
????private?List<T>dataList;//要顯示的數(shù)據(jù)
????
????
????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();
????????//獲取每頁顯示記錄數(shù)
????????this.pageSize=pageSize;
????????//獲取總頁數(shù)
????????this.totalPage=this.totalRecord/this.pageSize;
????????if(this.totalRecord%this.pageSize!=0){
????????????this.totalPage+=1;
????????}
????????//當(dāng)前第幾頁數(shù)據(jù)
????????if(this.totalPage<pageNum){
????????????this.currentPage=pageNum;
????????}else?{
????????????this.totalPage=pageNum;
????????}
????????
????????//開始索引
????????int?fromIndex=this.pageSize*(this.currentPage-1);
????????
????????//結(jié)束索引
????????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);
//兩種都有錯(cuò)?錯(cuò)誤提示:An?error?occurred?at?line:?31?in?the?jsp?file:?/admin/staff-right.jsp
'<>'?operator?is?not?allowed?for?source?level?below?1.7
//提示有錯(cuò)
2 回答
已采納

無聊的緘默
TA貢獻(xiàn)4條經(jīng)驗(yàn) 獲得超2個(gè)贊
你發(fā)的第100代碼 ? Pager<Employee> pager = new Pager<>(currentPage, pageSize, employees);
這種寫法只有在jdk1.7以上的版本才支持 后面的尖括號(hào)中省略類型
jdk1.5 ?1.6的版本 ?后方的尖括號(hào)中 也要寫 Employee 要和前面的 一直 才行

HansonQ
TA貢獻(xiàn)223條經(jīng)驗(yàn) 獲得超56個(gè)贊
你看下你的項(xiàng)目環(huán)境和編譯環(huán)境是不是都是1.7.
一般都是eclipse的編譯環(huán)境與項(xiàng)目的要求不對(duì)應(yīng)造成的,這個(gè)錯(cuò)誤一般是導(dǎo)入別的項(xiàng)目才出現(xiàn)的。
右鍵項(xiàng)目--屬性--勾選Enable project? specific? settings--Compiler compliance level--選擇1.7--OK
添加回答
舉報(bào)
0/150
提交
取消