分页

来源:互联网 发布:js点击关闭弹出框 编辑:程序博客网 时间:2024/06/03 17:24
<!-- 配置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";}
原创粉丝点击