本文整理汇总了Java中com.github.pagehelper.PageInfo.getPageNum方法的典型用法代码示例。如果您正苦于以下问题:Java PageInfo.getPageNum方法的具体用法?Java PageInfo.getPageNum怎么用?Java PageInfo.getPageNum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.github.pagehelper.PageInfo
的用法示例。
在下文中一共展示了PageInfo.getPageNum方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: index
import com.github.pagehelper.PageInfo; //导入方法依赖的package包/类
/**
* 首页
*
* @param request
* @return
* @throws Exception
*/
@RequestMapping("/index")
public ModelAndView index(HttpServletRequest request) throws Exception {
String page = request.getParameter("pagenum");
Integer pagenum;
if (StringUtils.isEmpty(page)) {
pagenum = 1;
} else {
pagenum = Integer.parseInt(page);
}
PageHelper.startPage(pagenum, 15);
ModelAndView mav = new ModelAndView();
List<Blog> lists = blogService.getAllBlog();
List<Blog> banners = blogService.getBanner();
PageInfo<Blog> blogs = new PageInfo<>(lists);
Integer startpage, endpage;
if (blogs.getPages() < 6) {
startpage = 1;
endpage = blogs.getPages();
} else {
if (pagenum > 3) {
startpage = blogs.getPageNum() - 3;
endpage = blogs.getPageNum() + 3 > blogs.getPages() ? blogs.getPages() : blogs.getPageNum() + 3;
} else {
startpage = 1;
endpage = blogs.getPageNum() + 4;
}
}
List<Blog> hotblogs = blogService.getByHits();
mav.addObject("startpage", startpage);
mav.addObject("endpage", endpage);
mav.addObject("hotblogs", hotblogs);
mav.addObject("blogs", blogs.getList());
mav.addObject("totalpages", blogs.getPages());
mav.addObject("pageNum", blogs.getPageNum());
mav.addObject("banners", banners);
mav.setViewName("index");
return mav;
}
示例2: to_show_article
import com.github.pagehelper.PageInfo; //导入方法依赖的package包/类
@RequestMapping("/tech")
public ModelAndView to_show_article(HttpServletRequest request) { //博客主页
ModelAndView modelAndView = new ModelAndView();
String page = request.getParameter("pagenum");
String categoryid = request.getParameter("categoryid");
String t_id = request.getParameter("tid");
Integer pagenum;
if (StringUtils.isEmpty(page)) {
pagenum = 1;
} else {
pagenum = Integer.parseInt(page);
}
PageHelper.startPage(pagenum, 15);
List<Blog> lists;
if (StringUtils.isNotEmpty(categoryid)) {
lists = blogService.getByCategoryId(Integer.parseInt(categoryid));
Category category = categoryService.selectByPrimaryKey(Integer.parseInt(categoryid));
modelAndView.addObject("category", category);
} else if (StringUtils.isNotEmpty(t_id)) {
lists = blogService.getBlogByTagId(Integer.parseInt(t_id));
Tag tag = blogService.getTagByTid(Integer.parseInt(t_id));
modelAndView.addObject("tag", tag);
} else {
lists = blogService.getAllTechBlog();
}
for (Blog list : lists) {
try {
int category_id = list.getCategoryid();//bug fix 2017-11-13
list.setCategory(categoryService.selectByPrimaryKey(category_id));
} catch (Exception e) {
logger.error("分类设置" + e);
}
}
PageInfo<Blog> blogs = new PageInfo<>(lists);
Integer startpage, endpage;
if (blogs.getPages() < 6) {
startpage = 1;
endpage = blogs.getPages();
} else {
if (pagenum > 3) {
startpage = blogs.getPageNum() - 3;
endpage = blogs.getPageNum() + 3 > blogs.getPages() ? blogs.getPages() : pagenum + 3;
} else {
startpage = 1;
endpage = blogs.getPageNum() + 4 > blogs.getPages() ? blogs.getPages() : pagenum + 4;
}
}
modelAndView.addObject("startpage", startpage);
modelAndView.addObject("endpage", endpage);
modelAndView.addObject("blogs", blogs.getList());
modelAndView.addObject("totalpages", blogs.getPages());
modelAndView.addObject("pageNum", blogs.getPageNum());
modelAndView.setViewName("tech");
return modelAndView;
}
示例3: search
import com.github.pagehelper.PageInfo; //导入方法依赖的package包/类
@RequestMapping(value = "/search")
public ModelAndView search(
@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "pagenum", required = false) Integer pagenum) {
ModelAndView modelAndView = new ModelAndView();
try {
if (pagenum == null) {
pagenum = 1;
}
List<Blog> lists = blogService.getLuceneBlog(pagenum, keyword, 10);
PageHelper.startPage(pagenum, 10);
PageInfo<Blog> blogs = new PageInfo<>(lists);
blogs.setPageSize(10);
blogs.setSize(10);
blogs.setPages(lists.size() / 10 == 0 ? lists.size() / 10 : lists.size() / 10 + 1);
Integer startpage, endpage;
if (blogs.getPages() < 6) {
startpage = 1;
endpage = blogs.getPages();
} else {
if (pagenum > 3) {
startpage = blogs.getPageNum() - 3;
endpage = blogs.getPageNum() + 3;
} else {
startpage = 1;
endpage = blogs.getPageNum() + 4;
}
}
modelAndView.addObject("startpage", startpage);
modelAndView.addObject("endpage", endpage);
modelAndView.addObject("blogs", blogs.getList());
modelAndView.addObject("totalpages", blogs.getPages());
modelAndView.addObject("pageNum", pagenum);
modelAndView.addObject("keyword", keyword);
modelAndView.setViewName("searchresult");
} catch (Exception e) {
e.printStackTrace();
logger.error("search" + e);
}
return modelAndView;
}
示例4: getbycategoryid
import com.github.pagehelper.PageInfo; //导入方法依赖的package包/类
@RequestMapping("/getbycategoryid")
public ModelAndView getbycategoryid(HttpServletRequest request, HttpServletResponse response) {
ModelAndView modelAndView = new ModelAndView();
Integer cid = Integer.parseInt(request.getParameter("cid"));
String page = request.getParameter("pagenum");
String categoryid = request.getParameter("categoryid");
String t_id = request.getParameter("tid");
if (cid == 0) {
try {
response.sendRedirect("life.html");
} catch (IOException e) {
logger.error("getbycategoryid", e);
}
}
Integer pagenum;
if (StringUtils.isEmpty(page)) {
pagenum = 1;
} else {
pagenum = Integer.parseInt(page);
}
PageHelper.startPage(pagenum, 15);
List<Blog> lists = blogService.getByCategoryId(cid);
PageInfo<Blog> blogs = new PageInfo<>(lists);
Integer startpage, endpage;
if (blogs.getPages() < 6) {
startpage = 1;
endpage = blogs.getPages();
} else {
if (pagenum > 3) {
startpage = blogs.getPageNum() - 3;
endpage = blogs.getPageNum() + 3 > blogs.getPages() ? blogs.getPages() : pagenum + 3;
} else {
startpage = 1;
endpage = blogs.getPageNum() + 4 > blogs.getPages() ? blogs.getPages() : pagenum + 4;
}
}
modelAndView.addObject("startpage", startpage);
modelAndView.addObject("endpage", endpage);
modelAndView.addObject("blogs", blogs.getList());
modelAndView.addObject("totalpages", blogs.getPages());
modelAndView.addObject("pageNum", blogs.getPageNum());
modelAndView.setViewName("tech");
return modelAndView;
}
示例5: toshowarticle
import com.github.pagehelper.PageInfo; //导入方法依赖的package包/类
@RequestMapping("/life")
public ModelAndView toshowarticle(HttpServletRequest request) { //生活笔记
String page = request.getParameter("pagenum");
String categoryid = request.getParameter("categoryid");
String t_id = request.getParameter("tid");
Integer pagenum;
if (StringUtils.isEmpty(page)) {
pagenum = 1;
} else {
pagenum = Integer.parseInt(page);
}
PageHelper.startPage(pagenum, 15);
List<Blog> lists;
if (StringUtils.isEmpty(categoryid)) {
lists = blogService.getLife();
} else if (!StringUtils.isEmpty(t_id)) {
lists = blogService.getBlogByTagId(Integer.parseInt(t_id));
} else {
lists = blogService.getByCategoryId(Integer.parseInt(categoryid));
}
ModelAndView modelAndView = new ModelAndView();
for (Blog list : lists) {
try {
int category_id = lists.get(0).getCategoryid();
list.setCategory(categoryService.selectByPrimaryKey(category_id));
} catch (Exception e) {
logger.error("datetimeparse error" + e);
}
}
if (categoryid != null && !categoryid.equals("")) {
Category category = categoryService.selectByPrimaryKey(Integer.parseInt(categoryid));
modelAndView.addObject("category", category);
} else {
if (t_id != null) {
Tag tag = blogService.getTagByTid(Integer.parseInt(t_id));
modelAndView.addObject("tag", tag);
}
}
PageInfo<Blog> blogs = new PageInfo<>(lists);
Integer startpage, endpage;
if (blogs.getPages() < 6) {
startpage = 1;
endpage = blogs.getPages();
} else {
if (pagenum > 3) {
startpage = blogs.getPageNum() - 3;
endpage = blogs.getPageNum() + 3 > blogs.getPages() ? blogs.getPages() : pagenum + 3;
} else {
startpage = 1;
endpage = blogs.getPageNum() + 4 > blogs.getPages() ? blogs.getPages() : pagenum + 4;
}
}
modelAndView.addObject("startpage", startpage);
modelAndView.addObject("endpage", endpage);
modelAndView.addObject("blogs", blogs.getList());
modelAndView.addObject("totalpages", blogs.getPages());
modelAndView.addObject("pageNum", blogs.getPageNum());
modelAndView.setViewName("life");
return modelAndView;
}