java利用PageHelper.startPage(page, pageSize)分页

代码如下:

	@RequestMapping(value = "/selectLockLog", produces = "text/html;charset=UTF-8")
 	@ResponseBody
 	public String selectLockLog(String deviceuid,@RequestParam(required=true,defaultValue="1")Integer page, 
			@RequestParam(required=false,defaultValue="20")Integer pageSize,HttpServletRequest request, HttpServletResponse response) {
  		Map result = new HashMap();
  		if(deviceuid!=null){
  			List list = new ArrayList();  			 			
  			FBalarm fBalarm = new FBalarm();
  			fBalarm.setDeviceuid(deviceuid);  			 			
  			PageHelper.startPage(page, pageSize);
  			List msg = fBalaRmService.findFBdevice(fBalarm);	
  			PageInfo pinfo = new PageInfo(msg);
  			if (msg.size()!=0) {
				for (int i = 0; i < msg.size(); i++) {							
						list.add(msg.get(i));												
				}								 					  						
  			}
  			result.put("total", pinfo.getTotal());
  			result.put("list", list);	
  		}else{
  			return null;
  		}
  				
		return JSON.toJSONString(result);		 
  	 }

如图解析:

java利用PageHelper.startPage(page, pageSize)分页_第1张图片

测试结果:

java利用PageHelper.startPage(page, pageSize)分页_第2张图片

 

 

 

你可能感兴趣的:(java)