需求:运用mysql,根据时间段,实现分页效果,其中页数和数量都是变动的。
SELECT ID,date,keyword,rank,goodsName,nid,goodUIL,goodsName,goodImg,price,freight,ReceivingNum,comment,comlocation,sellerName,uid,storeUIL,Shoptype,location,wangUrl,service from Comtyinfo WHERE date BETWEEN #{starttime} and #{endtime} LIMIT #{currentPage}, #{lineSize}
@RequestMapping("/ctyf")
public String getComtyinfo(String starttime,String endtime,String currentPages,String num)
{
//0 10 10 12
int currentPage = 0;//初始值
int pages = Integer.parseInt(currentPages);
int parseInt = Integer.parseInt(num);
currentPage=(pages -1)* parseInt;//第1页
int lineSize=parseInt;//每次显示200
Map map=new HashMap();
map.put("starttime", starttime);
map.put("endtime", endtime);
map.put("currentPage", currentPage);
map.put("lineSize", lineSize);
System.out.println(map);
List<Comtyinfo> comty=comtyDao.getHugoodsDetai(map);
System.out.println(comty.size());
return JSON.toJSONString(comty);
}