后台controller代码
@RequestMapping("/brand/list.do")
public String brandList(String name, Integer isDisplay, Integer pageNo, ModelMap modelMap) {
Brand brand = new Brand();
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotBlank(name)){
brand.setName(name);
sb.append("name=").append(name);
}
if(isDisplay !=null){
brand.setIsDisplay(isDisplay);
sb.append("&").append("isDisplay=").append(isDisplay);
}else{
brand.setIsDisplay(1);
sb.append("&").append("isDisplay=").append(1);
}
brand.setIsDisplay(isDisplay);
brand.setPageNo(Pagination.cpn(pageNo));
brand.setPageSize(5);
Pagination pagination = brandService.getBrandWithPage(brand);
String url = "/brand/list.do";
pagination.pageView(url, sb.toString());
modelMap.addAttribute("pagination", pagination);
modelMap.addAttribute("name", name);
modelMap.addAttribute("isDisplay", isDisplay);
return "brand/list";
}
service代码
@Transactional(readOnly = true)
public Pagination getBrandWithPage(Brand brand) {
Pagination pagination = new Pagination(brand.getPageNo(), brand.getPageSize(), brandDao.getBrandCount(brand));
pagination.setList(brandDao.getBrandWithPage(brand));
return pagination;
}
前台代码
<div class="page pb15">
<span class="r inb_a page_b">
<c:forEach items="${pagination.pageView }" var="page">
${page}
</c:forEach>
</span>
</div>