資源描述:
《jquery easyui DataGrid分頁(yè)操作》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫(kù)。
1、上午沒事抽空做了一個(gè)datagrid的入門例子,是結(jié)合struts2做的,剛下班了,也閑著沒事,就datagrid的再做進(jìn)一步的開發(fā);進(jìn)行分頁(yè)操作另外本人有一個(gè)習(xí)慣,拒絕轉(zhuǎn)載或者抄襲他人的東西.此外,事例源碼盡量完整,哪怕最簡(jiǎn)單的代碼也要寫的清楚.??先看效果:雖然說是入門的例子,但本人盡量做的詳細(xì)點(diǎn),以后會(huì)繼續(xù)更新,部分功能此外,為了后繼easyui的學(xué)習(xí),做了一個(gè)簡(jiǎn)單的框架:后臺(tái)采用hibernate2.5+struts2開發(fā):數(shù)據(jù)庫(kù)用mysql。紅色代碼標(biāo)記注意。?model層的數(shù)據(jù)??Student類packageorg.easyui.model;importjava.u
2、til.Date;publicclassStudent{?privateintid;?privateintage;?privateStringname;?privateDatebirthday;?privateStringclassName;?privatecharsex;??publicchargetSex(){??returnsex;?}?publicvoidsetSex(charsex){??this.sex=sex;?}?publicintgetAge(){??returnage;?}?publicvoidsetAge(intage){??this.age=age;?}?
3、publicDategetBirthday(){??returnbirthday;?}?publicvoidsetBirthday(Datebirthday){??this.birthday=birthday;?}?publicintgetId(){??returnid;?}?publicvoidsetId(intid){??this.id=id;?}?publicStringgetName(){??returnname;?}?publicStringgetClassName(){??returnclassName;?}?publicvoidsetName(Stringname)
4、{??this.name=name;?}?publicvoidsetClassName(StringclassName){??this.className=className;?}?}??DAO數(shù)據(jù)庫(kù)訪問層?接口EasyDao:packageorg.easyui.dao;importjava.util.List;importorg.easyui.model.Student;publicinterfaceEasyDao{?publicListgetStudent(intpage,introws);?publicintgetTotalPages(introws);}
5、接口實(shí)現(xiàn)類EasyDaoImpl:packageorg.easyui.dao;importjava.util.List;importorg.easyui.model.Student;importorg.easyui.util.UtilHibernate;importorg.hibernate.HibernateException;importorg.hibernate.Session;publicclassEasyDaoImplimplementsEasyDao{?@SuppressWarnings("unchecked")?publicListgetStude
6、nt(intpage,introws){??Listlist=null;??Sessionsession=UtilHibernate.getSession();??try{???session.beginTransaction();???Stringsql="fromStudent";???list=session.createQuery(sql)???????.setFirstResult((page-1)*rows)???????.setMaxResults(rows)???????.list();???session.getTransaction().co
7、mmit();??}catch(HibernateExceptione){???session.getTransaction().rollback();???e.printStackTrace();??}finally{???UtilHibernate.closeSession(session);??}????returnlist;?}?publicintgetTotalPages(){??Sessionsession=UtilHibernate.getSession();??i