1、接口分页类
package com.broadengate.business.service.iface;
import java.util.List;
@SuppressWarnings("rawtypes")
public interface PageClass {
/**
* 初始化分页信息
*/
public abstract void init();
/**
* 以下判断页的信息,只需getter方法(is方法)即可
* @return
*/
public abstract boolean isFirstPage();
public abstract boolean isLastPage();
public abstract boolean isHasPreviousPage();
public abstract boolean isHasNextPage();
public abstract List getList();
public abstract void setList(List list);
public abstract int getTotalPage();
public abstract void setTotalPage(int totalPage);
public abstract int getCurrentPage();
public abstract void setCurrentPage(int currentPage);
public abstract int getPageSize();
public abstract void setPageSize(int pageSize);
public abstract void setFirstPage(boolean isFirstPage);
public abstract void setLastPage(boolean isLastPage);
public abstract void setHasPreviousPage(boolean hasPreviousPage);
public abstract void setHasNextPage(boolean hasNextPage);
public abstract int getAllCount();
public abstract void setAllCount(int allCount);
public abstract int getStartPage();
public abstract void setStartPage(int startPage);
public abstract int getEndPage();
public abstract void setEndPage(int endPage);
public abstract int countTotalPage(final int pageSize,final int allRow);
public abstract int countOffset(final int pageSize,final int currentPage);
public abstract int countCurrentPage(int page);
}
2、实现分页类
package com.broadengate.business.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.broadengate.business.service.iface.PageClass;
/**
* @ClassName: PageClass
* @Description: 分页类
* @author 邓伟
* @date 2010-11-10 上午13:12:49
*/
@Service
@SuppressWarnings("rawtypes")
public class PageClassImpl implements PageClass {
private List list; //集合
private int allCount;
private int totalPage; //总页数
private int currentPage=0; //当前页
private int pageSize; //每页显示多少条数
private int endPageIndex;
public int getEndPageIndex() {
return endPageIndex;
}
public void setEndPageIndex(int endPageIndex) {
this.endPageIndex = endPageIndex;
}
private boolean isFirstPage; //是否为第一页
private boolean isLastPage; //是否为最后一页
private boolean hasPreviousPage; //是否有上一页
private boolean hasNextPage; //是否有下一页
//2010-12-1 添加 起始行 终止行
private int startPage;//起始行
private int endPage; //终止行
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#init()
*/
public void init() {
this.totalPage = totalPage;
this.isFirstPage = isFirstPage;
this.isLastPage = isLastPage;
this.hasPreviousPage = hasPreviousPage;
this.hasNextPage = hasNextPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isFirstPage()
*/
public boolean isFirstPage() {
return currentPage==1;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isLastPage()
*/
public boolean isLastPage() {
return currentPage==totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isHasPreviousPage()
*/
public boolean isHasPreviousPage() {
return currentPage!=1; //只要当前页不是第1页
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isHasNextPage()
*/
public boolean isHasNextPage() {
return currentPage!=totalPage; //只要当前页不是最后1页
}
/**
* 计算总页数
* ,静态方法,供外部直接通过类名调用
* @param pageSize 每页记录数
* @param allRow 总记录数
* @return 总页数
*/
public int countTotalPage(final int pageSize,final int allRow)
{
int totalPage=allRow%pageSize==0 ? allRow/pageSize :allRow/pageSize+1;
return totalPage;
}
/**
* 计算当前页开始记录
* @param pageSize 每页记录数
* @param currentPage 当前第几页
* @return 当前页开始记录号
*/
public int countOffset(final int pageSize,final int currentPage)
{
final int offset=pageSize*(currentPage-1);
return offset;
}
/**
* 计算当前页,若为0或者请求的URL中没有"?page=",则用1代替
* @param page 传入的参数(可能为空,即0,则返回1)
* @return 当前页
*/
public int countCurrentPage(int page)
{
final int curPage=(page==0?1:page);
return curPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getList()
*/
public List getList() {
return list;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setList(java.util.List)
*/
public void setList(List list) {
this.list = list;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getTotalPage()
*/
public int getTotalPage() {
return totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setTotalPage(int)
*/
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getCurrentPage()
*/
public int getCurrentPage() {
return currentPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setCurrentPage(int)
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getPageSize()
*/
public int getPageSize() {
return pageSize;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setPageSize(int)
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setFirstPage(boolean)
*/
public void setFirstPage(boolean isFirstPage) {
this.isFirstPage = isFirstPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setLastPage(boolean)
*/
public void setLastPage(boolean isLastPage) {
this.isLastPage = isLastPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setHasPreviousPage(boolean)
*/
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setHasNextPage(boolean)
*/
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getAllCount()
*/
public int getAllCount() {
return allCount;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setAllCount(int)
*/
public void setAllCount(int allCount) {
this.allCount = allCount;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getStartPage()
*/
public int getStartPage() {
return startPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setStartPage(int)
*/
public void setStartPage(int startPage) {
this.startPage = startPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getEndPage()
*/
public int getEndPage() {
return endPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setEndPage(int)
*/
public void setEndPage(int endPage) {
this.endPage = endPage;
}
}
3、例子调用方法
(dao或者service类)
public PageClassImpl getPageClassBySearch(int curentPageIndex,int pageSize,Labinfo labinfo,User user,String subjects){
String hql="from Labinfo e where e.user.grade like '%"+user.getGrade()+"%' " +" and e.subject like '%"+subjects+"%'";
String temp="";
if (labinfo!=null) {
if (labinfo.getLabname()!=null&&!"".equals(labinfo.getLabname().trim())) {
temp+=" and e.labname like '%"+labinfo.getLabname()+"%'";
}
if (labinfo.getUser()!=null&&labinfo.getUser().getUserName()!=null&&!"".equals(labinfo.getUser().getUserName().trim())) {
temp+=" and e.user.userName like '%"+labinfo.getUser().getUserName()+"%'";
}
if (labinfo.getTempTime()!=null&&!"".equals(labinfo.getTempTime().trim())) {
temp+=" and e.loadtime <='"+labinfo.getTempTime()+" 23:59:59'";
//temp+=" and e.time ='"+Labinfo.getTempTime()+"'";
}
if (labinfo.getUser()!=null&&labinfo.getUser().getClasses()!=null&&!"".equals(labinfo.getUser().getClasses().trim())) {
temp+=" and e.user.classes like '%"+labinfo.getUser().getClasses()+"%'";
}
}
hql+=temp;
//hql+=" order by e.zhang asc";
String countSql="select count(*) from Labinfo e where e.user.grade like '%"+user.getGrade()+"%' " +
" and e.subject like '%"+subjects+"%'";
countSql+=temp;
Query query=super.getSessionFactory().getCurrentSession().createQuery(countSql);
int count=Integer.valueOf(query.uniqueResult().toString());
PageClassImpl pageClassImpl=new PageClassImpl();
pageClassImpl.setAllCount(count);
pageClassImpl.setCurrentPage(curentPageIndex);
pageClassImpl.setPageSize(pageSize);
int pageCount=pageClassImpl.getAllCount()/pageClassImpl.getPageSize();
if (pageClassImpl.getAllCount()%pageClassImpl.getPageSize()!=0) {
pageCount=pageCount+1;
}
pageClassImpl.setEndPageIndex(pageCount);
query=super.getSessionFactory().getCurrentSession().createQuery(hql);
query.setFirstResult((curentPageIndex-1)*pageSize);
query.setMaxResults(pageSize);
pageClassImpl.setList(query.list());
return pageClassImpl;
}
4、action存放在作用域中
public String toDefaultLab(){
ActionContext.getContext().put("labList", labinfoService.getPageClassBySearch(start, 10, labinfo, user,subjects));
return "labindex";
}
5、jsp页面展示
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="tag" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="style/style.css" rel="stylesheet" type="text/css" />
<title></title>
</head>
<body style="padding:5px;">
<tag:if test="${labList.allCount==0 }">
<div style="text-align: center;">没有你要的数据!</div>
</tag:if>
<tag:if test="${labList.allCount!=0 }">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="content_tab">
<tr>
<td align="center" class="table_bg tc" >编号</td>
<td class="table_bg">名称 </td>
<td class="table_bg">章 </td>
<td class="table_bg">节 </td>
<td class="table_bg">上传时间</td>
<td align="center" class="table_bg tc">操作</td>
</tr>
<tag:forEach var="extr" items="${labList.list }">
<tr>
<td align="center" class="fb tc">${extr.id}</td>
<td class="tl">${extr.labname }</td>
<td class="tl">第${extr.chapter}章</td>
<td class="tl">第${extr.section}节</td>
<td align="center" class="tl">
<f:formatDate value="${extr.loadtime}" pattern="yyyy-MM-dd hh:mm:ss"/>
</td>
<td align="center">
<!--学生登陆,用户类型是2,所选择的科目:1是语文,2是数学,3是英语-->
<tag:if test="${sessionScope.session_userinfo.userType!='3' }">
<a href="${pageContext.request.contextPath }/labinfo!toUpdateLab.action?id=${extr.id}">修改</a>
<a href="${pageContext.request.contextPath }/labinfo!doDeleteLab.action?id=${extr.id}" onclick="return confirm('确定要删除吗?')">删除</a>
</tag:if>
<!--<a href="${pageContext.request.contextPath }/labinfo!doDown.action?fnamepath=${extr.filepath}">下载</a>
-->
<a href="${pageContext.request.contextPath }/labinfo!downFile.action?id=${extr.id}">打开</a>
</td>
</tr>
</tag:forEach>
</table>
<div class="scott">
当前第${labList.currentPage }页 总共${labList.allCount }条
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=1">首页</a>
<tag:if test="${labList.currentPage==1 }" var="falg1">
上一页
</tag:if>
<tag:if test="${labList.currentPage!=1 }">
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=${labList.currentPage-1}">上一页</a>
</tag:if>
<tag:if test="${labList.currentPage==extraList.endPageIndex }" var="falg2">
下一页
</tag:if>
<tag:if test="${labList.currentPage!=labList.endPageIndex }">
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=${labList.currentPage+1}">下一页</a>
</tag:if>
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=${labList.endPageIndex}">末页</a>
</div>
</tag:if>
</body>
</html>
注明:例子中与分页无关的代码可以删除!
package com.broadengate.business.service.iface;
import java.util.List;
@SuppressWarnings("rawtypes")
public interface PageClass {
/**
* 初始化分页信息
*/
public abstract void init();
/**
* 以下判断页的信息,只需getter方法(is方法)即可
* @return
*/
public abstract boolean isFirstPage();
public abstract boolean isLastPage();
public abstract boolean isHasPreviousPage();
public abstract boolean isHasNextPage();
public abstract List getList();
public abstract void setList(List list);
public abstract int getTotalPage();
public abstract void setTotalPage(int totalPage);
public abstract int getCurrentPage();
public abstract void setCurrentPage(int currentPage);
public abstract int getPageSize();
public abstract void setPageSize(int pageSize);
public abstract void setFirstPage(boolean isFirstPage);
public abstract void setLastPage(boolean isLastPage);
public abstract void setHasPreviousPage(boolean hasPreviousPage);
public abstract void setHasNextPage(boolean hasNextPage);
public abstract int getAllCount();
public abstract void setAllCount(int allCount);
public abstract int getStartPage();
public abstract void setStartPage(int startPage);
public abstract int getEndPage();
public abstract void setEndPage(int endPage);
public abstract int countTotalPage(final int pageSize,final int allRow);
public abstract int countOffset(final int pageSize,final int currentPage);
public abstract int countCurrentPage(int page);
}
2、实现分页类
package com.broadengate.business.service.impl;
import java.util.List;
import org.springframework.stereotype.Service;
import com.broadengate.business.service.iface.PageClass;
/**
* @ClassName: PageClass
* @Description: 分页类
* @author 邓伟
* @date 2010-11-10 上午13:12:49
*/
@Service
@SuppressWarnings("rawtypes")
public class PageClassImpl implements PageClass {
private List list; //集合
private int allCount;
private int totalPage; //总页数
private int currentPage=0; //当前页
private int pageSize; //每页显示多少条数
private int endPageIndex;
public int getEndPageIndex() {
return endPageIndex;
}
public void setEndPageIndex(int endPageIndex) {
this.endPageIndex = endPageIndex;
}
private boolean isFirstPage; //是否为第一页
private boolean isLastPage; //是否为最后一页
private boolean hasPreviousPage; //是否有上一页
private boolean hasNextPage; //是否有下一页
//2010-12-1 添加 起始行 终止行
private int startPage;//起始行
private int endPage; //终止行
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#init()
*/
public void init() {
this.totalPage = totalPage;
this.isFirstPage = isFirstPage;
this.isLastPage = isLastPage;
this.hasPreviousPage = hasPreviousPage;
this.hasNextPage = hasNextPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isFirstPage()
*/
public boolean isFirstPage() {
return currentPage==1;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isLastPage()
*/
public boolean isLastPage() {
return currentPage==totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isHasPreviousPage()
*/
public boolean isHasPreviousPage() {
return currentPage!=1; //只要当前页不是第1页
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#isHasNextPage()
*/
public boolean isHasNextPage() {
return currentPage!=totalPage; //只要当前页不是最后1页
}
/**
* 计算总页数
* ,静态方法,供外部直接通过类名调用
* @param pageSize 每页记录数
* @param allRow 总记录数
* @return 总页数
*/
public int countTotalPage(final int pageSize,final int allRow)
{
int totalPage=allRow%pageSize==0 ? allRow/pageSize :allRow/pageSize+1;
return totalPage;
}
/**
* 计算当前页开始记录
* @param pageSize 每页记录数
* @param currentPage 当前第几页
* @return 当前页开始记录号
*/
public int countOffset(final int pageSize,final int currentPage)
{
final int offset=pageSize*(currentPage-1);
return offset;
}
/**
* 计算当前页,若为0或者请求的URL中没有"?page=",则用1代替
* @param page 传入的参数(可能为空,即0,则返回1)
* @return 当前页
*/
public int countCurrentPage(int page)
{
final int curPage=(page==0?1:page);
return curPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getList()
*/
public List getList() {
return list;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setList(java.util.List)
*/
public void setList(List list) {
this.list = list;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getTotalPage()
*/
public int getTotalPage() {
return totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setTotalPage(int)
*/
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getCurrentPage()
*/
public int getCurrentPage() {
return currentPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setCurrentPage(int)
*/
public void setCurrentPage(int currentPage) {
this.currentPage = currentPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getPageSize()
*/
public int getPageSize() {
return pageSize;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setPageSize(int)
*/
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setFirstPage(boolean)
*/
public void setFirstPage(boolean isFirstPage) {
this.isFirstPage = isFirstPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setLastPage(boolean)
*/
public void setLastPage(boolean isLastPage) {
this.isLastPage = isLastPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setHasPreviousPage(boolean)
*/
public void setHasPreviousPage(boolean hasPreviousPage) {
this.hasPreviousPage = hasPreviousPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setHasNextPage(boolean)
*/
public void setHasNextPage(boolean hasNextPage) {
this.hasNextPage = hasNextPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getAllCount()
*/
public int getAllCount() {
return allCount;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setAllCount(int)
*/
public void setAllCount(int allCount) {
this.allCount = allCount;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getStartPage()
*/
public int getStartPage() {
return startPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setStartPage(int)
*/
public void setStartPage(int startPage) {
this.startPage = startPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#getEndPage()
*/
public int getEndPage() {
return endPage;
}
/* (non-Javadoc)
* @see com.broadengate.business.service.impl.PageClass#setEndPage(int)
*/
public void setEndPage(int endPage) {
this.endPage = endPage;
}
}
3、例子调用方法
(dao或者service类)
public PageClassImpl getPageClassBySearch(int curentPageIndex,int pageSize,Labinfo labinfo,User user,String subjects){
String hql="from Labinfo e where e.user.grade like '%"+user.getGrade()+"%' " +" and e.subject like '%"+subjects+"%'";
String temp="";
if (labinfo!=null) {
if (labinfo.getLabname()!=null&&!"".equals(labinfo.getLabname().trim())) {
temp+=" and e.labname like '%"+labinfo.getLabname()+"%'";
}
if (labinfo.getUser()!=null&&labinfo.getUser().getUserName()!=null&&!"".equals(labinfo.getUser().getUserName().trim())) {
temp+=" and e.user.userName like '%"+labinfo.getUser().getUserName()+"%'";
}
if (labinfo.getTempTime()!=null&&!"".equals(labinfo.getTempTime().trim())) {
temp+=" and e.loadtime <='"+labinfo.getTempTime()+" 23:59:59'";
//temp+=" and e.time ='"+Labinfo.getTempTime()+"'";
}
if (labinfo.getUser()!=null&&labinfo.getUser().getClasses()!=null&&!"".equals(labinfo.getUser().getClasses().trim())) {
temp+=" and e.user.classes like '%"+labinfo.getUser().getClasses()+"%'";
}
}
hql+=temp;
//hql+=" order by e.zhang asc";
String countSql="select count(*) from Labinfo e where e.user.grade like '%"+user.getGrade()+"%' " +
" and e.subject like '%"+subjects+"%'";
countSql+=temp;
Query query=super.getSessionFactory().getCurrentSession().createQuery(countSql);
int count=Integer.valueOf(query.uniqueResult().toString());
PageClassImpl pageClassImpl=new PageClassImpl();
pageClassImpl.setAllCount(count);
pageClassImpl.setCurrentPage(curentPageIndex);
pageClassImpl.setPageSize(pageSize);
int pageCount=pageClassImpl.getAllCount()/pageClassImpl.getPageSize();
if (pageClassImpl.getAllCount()%pageClassImpl.getPageSize()!=0) {
pageCount=pageCount+1;
}
pageClassImpl.setEndPageIndex(pageCount);
query=super.getSessionFactory().getCurrentSession().createQuery(hql);
query.setFirstResult((curentPageIndex-1)*pageSize);
query.setMaxResults(pageSize);
pageClassImpl.setList(query.list());
return pageClassImpl;
}
4、action存放在作用域中
public String toDefaultLab(){
ActionContext.getContext().put("labList", labinfoService.getPageClassBySearch(start, 10, labinfo, user,subjects));
return "labindex";
}
5、jsp页面展示
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="tag" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/My97DatePicker/WdatePicker.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="style/style.css" rel="stylesheet" type="text/css" />
<title></title>
</head>
<body style="padding:5px;">
<tag:if test="${labList.allCount==0 }">
<div style="text-align: center;">没有你要的数据!</div>
</tag:if>
<tag:if test="${labList.allCount!=0 }">
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="content_tab">
<tr>
<td align="center" class="table_bg tc" >编号</td>
<td class="table_bg">名称 </td>
<td class="table_bg">章 </td>
<td class="table_bg">节 </td>
<td class="table_bg">上传时间</td>
<td align="center" class="table_bg tc">操作</td>
</tr>
<tag:forEach var="extr" items="${labList.list }">
<tr>
<td align="center" class="fb tc">${extr.id}</td>
<td class="tl">${extr.labname }</td>
<td class="tl">第${extr.chapter}章</td>
<td class="tl">第${extr.section}节</td>
<td align="center" class="tl">
<f:formatDate value="${extr.loadtime}" pattern="yyyy-MM-dd hh:mm:ss"/>
</td>
<td align="center">
<!--学生登陆,用户类型是2,所选择的科目:1是语文,2是数学,3是英语-->
<tag:if test="${sessionScope.session_userinfo.userType!='3' }">
<a href="${pageContext.request.contextPath }/labinfo!toUpdateLab.action?id=${extr.id}">修改</a>
<a href="${pageContext.request.contextPath }/labinfo!doDeleteLab.action?id=${extr.id}" onclick="return confirm('确定要删除吗?')">删除</a>
</tag:if>
<!--<a href="${pageContext.request.contextPath }/labinfo!doDown.action?fnamepath=${extr.filepath}">下载</a>
-->
<a href="${pageContext.request.contextPath }/labinfo!downFile.action?id=${extr.id}">打开</a>
</td>
</tr>
</tag:forEach>
</table>
<div class="scott">
当前第${labList.currentPage }页 总共${labList.allCount }条
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=1">首页</a>
<tag:if test="${labList.currentPage==1 }" var="falg1">
上一页
</tag:if>
<tag:if test="${labList.currentPage!=1 }">
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=${labList.currentPage-1}">上一页</a>
</tag:if>
<tag:if test="${labList.currentPage==extraList.endPageIndex }" var="falg2">
下一页
</tag:if>
<tag:if test="${labList.currentPage!=labList.endPageIndex }">
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=${labList.currentPage+1}">下一页</a>
</tag:if>
<a href="${pageContext.request.contextPath }/labinfo!toDefaultLab.action?start=${labList.endPageIndex}">末页</a>
</div>
</tag:if>
</body>
</html>
注明:例子中与分页无关的代码可以删除!
发表评论
-
JNA入门1
2012-06-12 03:55 7371、jna是什么 jna是java native ac ... -
JNA—JNI 使用
2012-06-12 03:51 861原文地址(http://blog.csdn.net/sh ... -
在eclipse中修改java web项目的名称
2011-02-28 00:17 42561、首先在eclipse中更改项目名称(alt+shift+R ... -
DES加密比较实用
2011-02-21 10:54 766package com.broadengate.common; ... -
java必懂面试题
2011-02-21 10:49 728面试是没什么道理可讲的,他的题目有的不合情理、脱离实际。有在纸 ... -
利用DES加密算法保护Java源代码
2011-01-24 14:21 820利用DES加密算法保护Java源代码 ...
相关推荐
本示例着重讲解如何在S2SH框架下实现分页功能,这对于处理大量数据的展示和管理至关重要,能够提高用户体验并减轻服务器负载。 首先,我们来了解Struts2、Hibernate和Spring各自的角色: 1. **Struts2**:作为MVC...
在S2SH框架中,实现分页主要涉及以下几个步骤: 1. **配置Struts2的Action**:创建一个处理分页请求的Action类,这个类通常会包含当前页数、每页显示条数等参数,并且需要关联到对应的Action配置文件,定义请求路径...
S2SH框架,即Struts2、Hibernate3和Spring3的组合,是Java EE领域中广泛采用的一种集成方案。这个框架组合提供了模型-视图-控制器(MVC)的架构,数据持久化以及依赖注入等功能,极大地提升了开发效率和代码质量。 ...
在IT行业中,尤其是在Web开发领域,`s2sh`通常指的是Struts2、Spring和Hibernate三个框架的集成,它们一起构建了一个强大的Java EE应用程序开发框架。分页是Web应用中常见的功能,特别是在处理大量数据时,它能提高...
在这个特定的项目中,"s2sh基础框架实现增,删改查及分页的功能。连接oracle",我们主要讨论以下几个关键知识点: 1. **Struts2框架**:Struts2是基于MVC(Model-View-Controller)设计模式的Java Web框架,用于...
总结来说,S2SH项目中的分页组件通过封装分页逻辑,使得在Action和JSP中实现分页变得简单。开发者只需要关注设置分页参数和在JSP中渲染分页链接,而具体的数据库查询和结果处理则由DAO层处理。这种设计模式提高了...
在S2SH项目中实现分页,通常涉及以下几个步骤: 1. **Struts2配置**:在Struts2的配置文件(struts.xml)中,定义一个用于分页的Action,设置对应的Action方法和结果视图。 2. **Spring管理Bean**:创建一个Service...
S2SH框架是Java Web开发中常用的一个集成框架,它由Struts2、Spring和Hibernate三个组件构成: 1. **Struts2**:这是一个MVC(Model-View-Controller)框架,负责处理HTTP请求,将用户的交互与应用程序逻辑分离。...
在Java Web开发中,"S2SH"框架组合(Struts2、Hibernate和Spring)是常用的一种技术栈,它提供了强大的功能来构建企业级应用。本实例将深入探讨如何在S2SH框架下实现分页。 首先,让我们了解分页的基本概念。分页是...
在Java Web开发中,S2SH是一个经典的MVC(Model-View-Controller)架构,它将Struts2用于表现层,Spring作为业务逻辑层和依赖注入框架,Hibernate则处理数据持久化。Struts2负责处理用户请求并转发到相应的Action,...
本项目以"S2SH+MySql"(即Struts2、Hibernate、Spring与MySQL数据库)为基础,实现了分页功能,下面将详细介绍这一技术及其实施过程。 首先,Struts2是Java企业级开发中的一个MVC框架,负责处理用户请求并转发到...
2. **分页**:为了便于用户浏览大量数据,系统实现了分页展示用户列表,这通常需要在后台计算总条数和每页显示的数量,然后配合Struts2的动作和JSP页面实现分页展示。 3. **登录权限**:仅管理员("admin")可以登录...
本文将详细介绍一个能够继承Struts2+Spring+Hibernate(S2Sh)框架的优秀万能分页组件的设计与实现过程。 #### 二、设计思路 本案例中的“万能分页”主要通过以下几个步骤来实现: 1. **项目搭建**:首先需要创建...
总结来说,“封装好直接使用的jsp分页插件”是一个功能全面、配置简单的Java Web分页组件,它可以让开发者从复杂的分页逻辑中解放出来,将重点放在业务逻辑的实现上。然而,开发者在选择使用时,也应留意其在性能...
**S2SH分页功能详解** S2SH(Struts2 + Spring + Hibernate)是一个经典的Java Web开发框架组合,常用于构建企业级...通过这个项目,你可以学习到如何在实际开发中实现一个完整的分页功能,提升你的Java Web开发技能。
通过这样的流程,"demos2sh控制.zip"中的代码可以作为一个学习S2SH框架分页功能的实例,帮助开发者理解如何在实际项目中实现高效的分页效果。无论是初学者还是有经验的开发者,都能从中受益,提升自己的编程技能。
【标题】:“(仿铁路网上售票系统+google数字分页)S2SH 的小项目”指的是一款基于S2SH框架开发的模拟铁路网上售票系统的应用程序。S2SH是Struts2、Spring和Hibernate三个开源Java框架的组合,常用于构建企业级Web...
总之,SSH实例代码提供了基础的用户管理功能,通过Spring、Struts2和Hibernate的整合,展示了如何在Java Web开发中实现业务逻辑、数据访问和用户交互。对于希望深入学习Java Web开发的开发者来说,这是一个很好的...
总之,`S2SH整合pager-taglibs`的示例展示了如何在Struts2框架下利用标签库实现数据的高效分页展示,这在处理大量数据时尤为重要。通过合理的配置和代码编写,我们可以创建出用户友好、性能优秀的Web应用。在实际...
在S2SH框架下实现分页查询,我们通常会创建一个专门的`PageBean`类来封装分页信息。如描述中的代码所示,`PageBean`包含了以下几个关键属性: 1. `List list`:存储某一页的数据记录。 2. `int allRow`:记录总数量...