<!-- 配置ssm 在SpringMVC 中 或Springboot中的SqlMapConfig.xml中--><!-- 配置分页插件 -->< plugins >< plugin interceptor ="com.github.pagehelper.PageHelper" ><!-- 设置数据库类型 Oracle,Mysql,MariaDB,SQLite,Hsqldb,PostgreSQL六种数据库-->< property name ="dialect" value ="mysql" /></ plugin ></ plugins >@RequestMapping("/select") public String select(String sname,String pageNo,String pageSize,HttpServletRequest request){ int num = 1; int size=2; if(pageNo!=null && pageNo!=""){ num = Integer.parseInt(pageNo); } if(pageSize!=null && pageSize!=""){ size=Integer.parseInt(pageSize); } List<Stock> list = null; String str = jedisUtil.get("kuList"); if(str==null){ list = service.select(sname); String s = JSON.toJSONString(list); jedisUtil.set("kuList",s,10000); }else{ list = (List<Stock>) JSON.parse(str); } //开始分页 PageHelper.startPage(num,size); //调用方法 list = service.select(sname); //放到作用域中 PageInfo<Stock> info = new PageInfo<>(list); request.setAttribute("info",info); return "main"; }
分页
最新推荐文章于 2022-07-15 11:03:08 发布