this.tiao_zong = tiao_zong;
}
}
创建一个IPageDao的接口:
public interface IPageDao {
//定义一个接口
public List findByPage(Page p);
}
创建出来实体类PageDaoImpl:
public class PageDaoImpl implements IPageDao {
public List findBypage(Page p) {
// TODO Auto-generated method stub
Session session=sessionFactory.getCurrentSession();
Criteria cri=session.createCriteria(Page.class);
cri.setFirstResult((p.getDangqian()-1)*p.getTiao_size()).setMaxResults(p.getTiao_size());
return cri.list();
}
}
创建出来业务逻辑层IPageService:
public interface IPageService {
//定义一个接口
public List findByPage(Page p);
}
创建出来业务逻辑层的实体类PageServiceImpl:
public class PageServiceImpl implements IPageService {
private IPageDao ipd;
public List findBypage(Page p) {
// TODO Auto-generated method stub
return ipd.findBypage§;
}
}
创建一个Action层PageAction:
注意:这里需要封装!!所定义的类 但是我省略掉了
public class PersonnelAction extends ActionSupport {
private IPersonnelService ips;
//分页
private Page p=new Page();
private int ye;
private int ye_zong;
private int tiaoshu;
public String findbypage(){
//得到总条数
tiaoshu=2;
int tiao=ips.findAll().size();
//计算页数
if(tiao%tiaoshu!=0){ p.setPage_zong((tiao/tiaoshu)+1);}else{
p.setPage_zong(tiao/tiaoshu); }
p.setTiao_size(tiaoshu);
if(ye>p.getPage_zong()){
ye=p.getPage_zong();
}if(ye==0){
ye=1;
}
p.setDangqian(ye);
ye_zong=p.getPage_zong();
list_per=ips.findBypage§;
return “show”;
}
}
下面是JSP页面:
index.jsp:
<%@ page language=“java” import=“java.util.*” pageEncoding=“UTF-8”%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+“😕/”+request.getServerName()+“:”+request.getServerPort()+path+“/”;
%>
list_p 界面 :
注意:在table外边写上一页—下一页。。。。。这里我就省略掉了
<%@ page language=“java” import=“java.util.*” pageEncoding=“UTF-8”%>
<%@ taglib prefix=“c” uri=“http://java.sun.com/jsp/jstl/core” %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+“😕/”+request.getServerName()+“:”+request.getServerPort()+path+“/”;
%>
最后
分布式技术专题+面试解析+相关的手写和学习的笔记pdf
还有更多Java笔记分享如下:
st.getScheme()+“😕/”+request.getServerName()+“:”+request.getServerPort()+path+“/”;
%>
最后
分布式技术专题+面试解析+相关的手写和学习的笔记pdf
还有更多Java笔记分享如下:
[外链图片转存中…(img-fPT8974P-1714503887554)]