Paged Query case

Source: Internet
Author: User

Paging Query


/*** All members are queried by paging.* @param page* @param request* @return*/
@RequestMapping ("/")public string Getallstaff (string page,httpservletrequest request){if (page ==null){page = 1+ "";}Request.setattribute ("page", page);Request.setattribute ("Pagenum", Staffservice.getpagenum ());Request.setattribute ("Stafflist", Staffservice.allstaff (page));return "/";}
/*** Paging Query Next page* @param page* @param request* @return*/@RequestMapping ("/")public string NextPage (string Page,httpservletrequest request) {int curpage = integer.parseint (page);Request.setattribute ("page", curpage+1);Request.setattribute ("Pagenum", Staffservice.getpagenum ());Request.setattribute ("Stafflist", Staffservice.allstaff (curpage+1+ ""));return "/";}/*** Paged Query Previous page* @param page* @param request* @return*/
@RequestMapping ("/")public string PrevPage (string Page,httpservletrequest request) {int curpage = integer.parseint (page);Request.setattribute ("page", curPage-1);Request.setattribute ("Pagenum", Staffservice.getpagenum ());Request.setattribute ("Stafflist", Staffservice.allstaff (curpage-1+ ""));return "/";}


/*** Paged Query Member information* @param page* @return*/Public list<staff> Allstaff (String page);

/*** Get page numbers.* @return*/public int getpagenum ();

/*** Paged Query Member information* @param page* @return*/Public list<staff> Allstaff (String page) {return Staffdao.allstaff (page);}

/*** Get page numbers.* @return*/public int Getpagenum () {return Staffdao.getpagenum ();}


public int getpagenum ();Public list<staff> Allstaff (String page);

/*** Get total page number information for employee pages.*/public int Getpagenum (){String hql= "from staff";Query query = sessionfactory.getcurrentsession (). CreateQuery (HQL);int temp = Query.list (). Size ()/pagesize;//size=10if (Query.list (). Size ()%pagesize!=0){temp++;}return temp;}

/*** Paging gets all employees, on the first page.*/Public list<staff> Allstaff (String page){String hql= "from staff";Query query = sessionfactory.getcurrentsession (). CreateQuery (HQL);Query.setfirstresult ((Integer.parseint (page)-1) *pagesize);Query.setmaxresults (pageSize);return Query.list ();}

From for notes (Wiz)

Paged Query case

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.