- 浏览: 35889 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
alan_zyy:
学习了
jsp文件上传 -
tinguo002:
O也, 受益
不过楼主要是给个例子来就好了,
我的疑惑主要是在 ...
struts1.2分页方法小结
分页代码:
首先是分页对象:
服务层调用分页:
struts1 web action
vo
actionForm
web 项面
page.jsp
相关页面调用
以上是一些分页的部分代码。。
首先是分页对象:
package sboss.framework.dao.util; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 2010-8-9 * Time: 9:49:12 * To change this template use File | Settings | File Templates. */ public class Page { public final int DEFAULT_PAGESIZE = 10;//默认10条一页 public final int DEFAULT_PAGE = 1; //默认从第一页开始 public final int DEFAULT_STARTINDEX = 0;//默认从第0条记录开始 private int totalNum ; //总记录数 private int pageSize; //每页记录数 private int pageCount; //总页数 private int pageNum; //当前页码 private int startIndex; //起始记录下标 private boolean init; //默认是false,当为true时,表示page初始完成,否则不可用 private PType pt; public static enum PType { STARTINDEX,//指示表示参数为 记录下标 PAGENUM, //指示表示参数为 页码 } public Page(){ this.pageSize = DEFAULT_PAGESIZE; this.pageNum = DEFAULT_PAGE; this.startIndex = DEFAULT_STARTINDEX; //默认是页码的形式 this.pt=PType.PAGENUM; } public Page(int pageSize,int param,PType pt){ this.pageSize = pageSize<1 ? 1 : pageSize; this.pt = pt; if(PType.PAGENUM.equals(this.pt)){ this.pageNum = param<1 ? 1 : param; }else if(PType.STARTINDEX.equals(this.pt)){ this.startIndex = param<0 ? 0 : param; } } public void setTotalNum(int totalNum) { this.totalNum = totalNum<0 ? 0 : totalNum; this.pageCount = (this.totalNum+pageSize-1)/pageSize; if(PType.PAGENUM.equals(this.pt)){ if(pageNum>pageCount) pageNum = pageCount; if(pageNum<1) pageNum = 1; this.startIndex = (pageNum-1)*pageSize; }else if(PType.STARTINDEX.equals(this.pt)){ if(startIndex>=this.totalNum){ this.startIndex = (this.totalNum-1<0)? 0 : this.totalNum-1; } this.pageNum = (this.startIndex+this.pageSize)/this.pageSize; }else{ this.pageNum = DEFAULT_PAGE; this.startIndex = DEFAULT_STARTINDEX; } this.init = true; } public boolean isInit() { return init; } public int getTotalNum() { return totalNum; } public int getPageSize() { return pageSize; } public int getPageCount() { return pageCount; } public int getStartIndex() { return startIndex; } public int getPageNum() { return pageNum; } public void setPageNum(int pageNum) { this.pageNum = pageNum; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public void setPageCount(int pageCount) { this.pageCount = pageCount; } public void setStartIndex(int startIndex) { this.startIndex = startIndex; } }
package sboss.framework.model; /** * User: Administrator * Date: 2006-2-13 * Time: 15:09:40 */ public class PageInfo { // this is sign, which means the-last-page // and is useful when a new object is added and // the last-page is not know. // if the currentPage is set THE_LAST_PAGE, // those *list* function should re-calculate the currentPage // and set it be the REAL last page. public static int THE_LAST_PAGE = 100000; public PageInfo() { } public PageInfo(int pageSize, int currentPage) { this.pageSize = pageSize; this.currentPage = currentPage; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getCurrentPage() { return currentPage; } public void setCurrentPage(int currentPage) { this.currentPage = currentPage; } public int getTotal() { return total; } public void setTotal(int total) { this.total = total; } public String getDestURL() { return destURL; } public void setDestURL(String destURL) { this.destURL = destURL; } /** * * @return a mysql page-split sql-string */ public String toMySqlString() { StringBuffer sb = new StringBuffer(); sb.append(" limit ").append(this.getStartIndex()); sb.append(",").append(this.pageSize); return sb.toString(); } /** * @return the query start position */ public int getStartIndex() { return (this.currentPage - 1) * this.pageSize;// + 1; } /** * */ public int getTotalPages() { int i = this.total / this.pageSize; int m = this.total % this.pageSize; //return i < 1 && this.total > 0 ? 1 : i; return i + (m != 0 ? 1 : 0); } private int pageSize; private int currentPage; private int total; private String destURL; }
服务层调用分页:
package sboss.serviceCall.service.impl; import sboss.serviceCall.service.ServiceCallService; import sboss.serviceCall.entity.ServiceCall; import sboss.serviceCall.dao.ServiceCallDAO; import sboss.serviceCall.vo.ServiceCallVo; import sboss.framework.dao.util.Page; import sboss.framework.dao.util.IQueryCallback; import java.util.List; import java.util.Date; import java.util.ArrayList; import java.text.DateFormat; import java.text.SimpleDateFormat; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Propagation; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.Criteria; import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Order; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 2010-12-10 * Time: 16:48:39 * To change this template use File | Settings | File Templates. */ @Transactional(propagation= Propagation.REQUIRED) public class ServiceCallServiceImpl implements ServiceCallService { private static Log log = LogFactory.getLog(ServiceCallServiceImpl.class); private ServiceCallDAO serviceCalldao; public ServiceCallDAO getServiceCalldao() { return serviceCalldao; } public ServiceCallVo selectServiceCall(final ServiceCallVo serviceCallVo, Page page) { List<ServiceCall> list = null; list = this.serviceCalldao.listByCriteria(new IQueryCallback(){ public Criteria initCriteria(Criteria criteriac){ // DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss" ); String scType = "0"; criteriac.add(Restrictions.eq(("status"),scType)); criteriac.add(Restrictions.eq(("deleteFlag"),0)); // 操作人 criteriac.add(Restrictions.or(Restrictions.eq("owner",serviceProductVO.getOwnerID()),Restrictions.eq("creator",serviceProductVO.getOwnerID()))); return criteriac; } public Criteria addOrders(Criteria criteria){ if("desc".equals(serviceCallVo.getOrderdesc())){ criteria.addOrder(Order.desc(serviceCallVo.getOrderBy())); } else{ criteria.addOrder(Order.asc(serviceCallVo.getOrderBy())); } return criteria; } },page); ServiceCallVo scVo = new ServiceCallVo(); scVo.setList(list); scVo.setPage(page); return scVo; } }
struts1 web action
package sboss.serviceCall.web.action; import sboss.framework.web.action.AbstractDispatchActionSupport; import sboss.serviceCall.service.ServiceCallService; import sboss.serviceCall.web.form.ServiceCallForm; import sboss.serviceCall.vo.ServiceCallVo; import sboss.serviceCall.entity.ServiceCall; import sboss.framework.client.UtilClient; import sboss.framework.dao.util.Page; import sboss.framework.model.PageInfo; import sboss.hr.model.Staff; import org.apache.struts.action.ActionForward; import org.apache.struts.action.ActionMapping; import org.apache.struts.action.ActionForm; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import java.util.*; import java.text.SimpleDateFormat; /** * Created by IntelliJ IDEA. * User: Rao Lin * Date: 2010-12-10 * Time: 17:19:21 * To change this template use File | Settings | File Templates. */ public class ServiceCallAction extends AbstractDispatchActionSupport { /** * 服务首页(查询出所有可用的服务产品) */ public ActionForward showIndex(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ServiceCallService serviceCallService = (ServiceCallService)this.getWebApplicationContext().getBean("serviceCallService"); String search=request.getParameter("search")==null?"":request.getParameter("search"); int countRecord= 0; //记录总条数 ServiceCallForm scForm = (ServiceCallForm)form; ServiceCallVo serviceCallVo = new ServiceCallVo(); String startTime = scForm.getCreate_time() ==null?"":scForm.getCreate_time(); List serviceCallList = null; if(search.equals("false")){ } else{ } UtilClient util = new UtilClient(); Staff staff=util.getCurrentStaff(request); String ownerID = staff.getId(); // serviceCallVo.setCallUser_ID(ownerID); String orderbyname =request.getParameter("orderbyname")==null?"":request.getParameter("orderbyname"); String orderdesc=request.getParameter("orderdesc")==null?"":request.getParameter("orderdesc"); String serviceCallType = request.getParameter("status")==null?"":request.getParameter("status"); //设置查询表单类型 if(orderbyname.equals("") && orderdesc.equals("")){ //根据创建时间降序排序 orderbyname="create_time"; orderdesc="desc"; serviceCallVo.setOrderBy(orderbyname); serviceCallVo.setOrderdesc(orderdesc); }else{ if(orderbyname.equals("create_time")){ serviceCallVo.setOrderBy(orderbyname); serviceCallVo.setOrderdesc(orderdesc); }else{ serviceCallVo.setOrderBy(orderbyname); serviceCallVo.setOrderdesc(orderdesc); } } request.setAttribute("orderbyname",orderbyname); request.setAttribute("orderdesc",orderdesc); PageInfo pageInfo = (PageInfo) request.getAttribute("pageInfo"); String pageSize = request.getParameter("pageSize"); String currentPage = request.getParameter("currentPage"); Page page = new Page(pageSize!=null ? Integer.parseInt(pageSize) : 10, currentPage!=null ? Integer.parseInt(currentPage) : 1,Page.PType.PAGENUM); ServiceCallVo selectServiceCall; //创建个vo对象用于接收service查询之后的返回对象 Page selectPage ; selectServiceCall = serviceCallService.selectServiceCall(serviceCallVo,page); selectPage = selectServiceCall.getPage(); pageInfo.setPageSize(selectPage.getPageSize()); //设置页面显示条数 pageInfo.setCurrentPage(selectPage.getPageNum()); //设置当前页码 pageInfo.setTotal(selectPage.getTotalNum()); //设置总记录数 request.setAttribute("pageInfo",pageInfo); //设置分页 request.setAttribute("serviceCallList",selectServiceCall.getList()); request.setAttribute("status",serviceCallType); countRecord = pageInfo.getTotal(); request.setAttribute("countRecord",countRecord); return mapping.findForward("showServiceCallIndex"); } } }
vo
package sboss.serviceCall.vo; import sboss.serviceCall.entity.ServiceCall; import sboss.framework.dao.util.Page; import java.util.List; import java.util.Date; /** * Created by IntelliJ IDEA. * User: Administrator * Date: 2010-12-13 * Time: 10:09:18 * To change this template use File | Settings | File Templates. */ public class ServiceCallVo { private int id;//表单ID private String serviceCallNo ; // 服务请求单编号 private String customer_ID ; // 服务请求单客户id private String customer_Name ; // 服务请求单客户名称 private String contact_ID ; // 服务请求单客户服务合同 private Integer channel_ID ; // 服务商ID private String telephone ; // 服务请求人电话 private String address ; // 服务请求人人地址 private String email ; // 服务请求人人电子邮件 private String callUser_ID ; // 服务请求人人ID private String callUser_Name ; // 服务请求人人名称 private String description ; // 服务请求人内容 private Date call_time ; // 服务请求人时间 private Date replay_time ; // 回访时间 private String replay_result ; // 回访结果 private Date close_time ; // 服务请求人关闭时间 private Date create_time ; // 服务请求人创建时间 private String creator ; // 服务请求人创建人 private String status ; // 服务请求人告单状态 private String subject ; // 主题 private String orderdesc ; //升序,或者降序 private String orderBy ; //根据XX排序 private List<ServiceCall> list; //serviceProductList集合,用于和service层交互 private Page page; public int getId() { return id; } public void setId(int ID) { this.id = ID; } public String getServiceCallNo() { return serviceCallNo; } public void setServiceCallNo(String serviceCallNo) { this.serviceCallNo = serviceCallNo; } public String getCustomer_ID() { return customer_ID; } public void setCustomer_ID(String customer_ID) { this.customer_ID = customer_ID; } public String getCustomer_Name() { return customer_Name; } public void setCustomer_Name(String customer_Name) { this.customer_Name = customer_Name; } public String getContact_ID() { return contact_ID; } public void setContact_ID(String contact_ID) { this.contact_ID = contact_ID; } public Integer getChannel_ID() { return channel_ID; } public void setChannel_ID(Integer channel_ID) { this.channel_ID = channel_ID; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getCallUser_ID() { return callUser_ID; } public void setCallUser_ID(String callUser_ID) { this.callUser_ID = callUser_ID; } public String getCallUser_Name() { return callUser_Name; } public void setCallUser_Name(String callUser_Name) { this.callUser_Name = callUser_Name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public Date getCall_time() { return call_time; } public void setCall_time(Date call_time) { this.call_time = call_time; } public Date getReplay_time() { return replay_time; } public void setReplay_time(Date replay_time) { this.replay_time = replay_time; } public String getReplay_result() { return replay_result; } public void setReplay_result(String replay_result) { this.replay_result = replay_result; } public Date getClose_time() { return close_time; } public void setClose_time(Date close_time) { this.close_time = close_time; } public Date getCreate_time() { return create_time; } public void setCreate_time(Date create_time) { this.create_time = create_time; } public String getCreator() { return creator; } public void setCreator(String creator) { this.creator = creator; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getOrderdesc() { return orderdesc; } public void setOrderdesc(String orderdesc) { this.orderdesc = orderdesc; } public List<ServiceCall> getList() { return list; } public void setList(List<ServiceCall> list) { this.list = list; } public String getOrderBy() { return orderBy; } public void setOrderBy(String orderBy) { this.orderBy = orderBy; } public Page getPage() { return page; } public void setPage(Page page) { this.page = page; } }
actionForm
package sboss.serviceCall.web.form; import org.apache.struts.action.ActionForm; /** * Created by IntelliJ IDEA. * User: Rao Lin * Date: 2010-12-10 * Time: 17:18:27 * To change this template use File | Settings | File Templates. */ public class ServiceCallForm extends ActionForm{ private int id ;// 表单ID private String serviceCallNo ; // 服务请求单编号 private String customer_ID ; // 服务请求单客户id private String customer_Name ; // 服务请求单客户名称 private String contact_ID ; // 服务请求单客户服务合同 private Integer channel_ID ; // 服务商ID private String telephone ; // 服务请求人电话 private String address ; // 服务请求人人地址 private String email ; // 服务请求人人电子邮件 private String callUser_ID ; // 服务请求人人ID private String callUser_Name ; // 服务请求人人名称 private String description ; // 服务请求人内容 private String call_time ; // 服务请求人时间 private String replay_time ; // 回访时间 private String replay_result ; // 回访结果 private String close_time ; // 服务请求人关闭时间 private String create_time ; // 服务请求人创建时间 private String creator ; // 服务请求人创建人 private String status ; // 服务请求人告单状态 private String subject ; // 主题 public int getId() { return id; } public void setId(int ID) { this.id = ID; } public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } public String getServiceCallNo() { return serviceCallNo; } public void setServiceCallNo(String serviceCallNo) { this.serviceCallNo = serviceCallNo; } public String getCustomer_ID() { return customer_ID; } public void setCustomer_ID(String customer_ID) { this.customer_ID = customer_ID; } public String getCustomer_Name() { return customer_Name; } public void setCustomer_Name(String customer_Name) { this.customer_Name = customer_Name; } public String getContact_ID() { return contact_ID; } public void setContact_ID(String contact_ID) { this.contact_ID = contact_ID; } public Integer getChannel_ID() { return channel_ID; } public void setChannel_ID(Integer channel_ID) { this.channel_ID = channel_ID; } public String getTelephone() { return telephone; } public void setTelephone(String telephone) { this.telephone = telephone; } public String getAddress() { return address; } public void setAddress(String address) { this.address = address; } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } public String getCallUser_ID() { return callUser_ID; } public void setCallUser_ID(String callUser_ID) { this.callUser_ID = callUser_ID; } public String getCallUser_Name() { return callUser_Name; } public void setCallUser_Name(String callUser_Name) { this.callUser_Name = callUser_Name; } public String getDescription() { return description; } public void setDescription(String description) { this.description = description; } public String getCall_time() { return call_time; } public void setCall_time(String call_time) { this.call_time = call_time; } public String getReplay_time() { return replay_time; } public void setReplay_time(String replay_time) { this.replay_time = replay_time; } public String getReplay_result() { return replay_result; } public void setReplay_result(String replay_result) { this.replay_result = replay_result; } public String getClose_time() { return close_time; } public void setClose_time(String close_time) { this.close_time = close_time; } public String getCreate_time() { return create_time; } public void setCreate_time(String create_time) { this.create_time = create_time; } public String getCreator() { return creator; } public void setCreator(String creator) { this.creator = creator; } public String getStatus() { return status; } public void setStatus(String status) { this.status = status; } }
web 项面
page.jsp
<%@ include file="taglib.jsp" %> <script language="javascript"> var NEXT = 1; var PREV = -1; // default page form var formObject = document.forms[0]; function next() { concatURL(formObject, NEXT); formObject.submit(); } function prev() { concatURL(formObject, PREV); formObject.submit(); } function gopage(page_no) { concatURL_page(formObject, page_no); formObject.submit(); } function concatURL(formObject, flag) { var currentPage = ${pageInfo.currentPage} + flag * 1 ; var thisAction = formObject.action; thisAction += (-1 == thisAction.indexOf("?") ? "?" : "&" ) + "pageSize=${pageInfo.pageSize}" + "¤tPage=" + currentPage; formObject.action = thisAction; } function concatURL_page(formObject, page_number) { var currentPage = page_number ; var thisAction = formObject.action; thisAction += (-1 == thisAction.indexOf("?") ? "?" : "&" ) + "pageSize=${pageInfo.pageSize}" + "¤tPage=" + currentPage; formObject.action = thisAction; } function pageSetForm(f) { formObject = f; } function setCustomePageTitle(customPageTitle) { document.all.custom_page_title.innerHTML = customPageTitle; } </script> <table border="0" width="100%" cellpadding="0" cellspacing="0"> <tr> <td id="custom_page_title"> </td> <td width="300"> <c:if test="${not dont_show_total}"> <bean:message key="page.info" arg0="${pageInfo.total}" arg1="${pageInfo.pageSize}" arg2="${pageInfo.currentPage}" arg3="${pageInfo.totalPages}" /> </c:if> </td> <%-- <td width="160"> <fmt:message key="page.current_page"/> <b><font color="red">${pageInfo.currentPage}</font></b> / <b><font color="red"> <fmt:formatNumber value="${pageInfo.totalPages}" pattern="#####"/> </font></b> </td> --%> <td width="80"> <c:if test="${pageInfo.currentPage > 1}"> <a href="javascript:gopage('1')" ><fmt:message key="page.first" /></a> <a href="javascript:prev()"><fmt:message key="page.prev"/></a> </c:if> <c:if test="${pageInfo.currentPage <= 1}"> <font color="#d6d6d6"><fmt:message key="page.first"/></font> <font color="#d6d6d6"><fmt:message key="page.prev"/></font> </c:if> </td> <td width="80"> <c:if test="${pageInfo.currentPage < pageInfo.totalPages}"> <a href="javascript:next()"><fmt:message key="page.next"/></a> <a href="javascript:gopage('${pageInfo.totalPages}')" ><fmt:message key="page.last" /></a> </c:if> <c:if test="${pageInfo.currentPage >= pageInfo.totalPages}"> <font color="#d6d6d6"><fmt:message key="page.next"/></font> <font color="#d6d6d6"><fmt:message key="page.last"/></font> </c:if> </td> </tr> </table>
相关页面调用
<%-- Created by IntelliJ IDEA. User: rl Date: 2010-12-11 Time: 19:06:22 To change this template use File | Settings | File Templates. --%> <%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ include file="../taglib.jsp" %> <%@ include file="../header.jsp" %> <link rel="stylesheet" href='${pageContext.request.contextPath}/config/public.css' type="text/css"> <link rel="stylesheet" href='${pageContext.request.contextPath}/config/index.css' type="text/css"> <script type="text/javascript" > function set_title() { top.frames.fraRightFrame.frames.fraContentBar.changeTitle('<fmt:message key="sc.menu"/>'); } window.onload=set_title; function orderby(name){ var orderbyname=document.forms[0].orderbyname.value; var orderdesc=document.forms[0].orderdesc.value; if(name==orderbyname){ if(orderdesc==""){ document.forms[0].orderdesc.value="desc"; }else{ document.forms[0].orderdesc.value=""; } }else{ document.forms[0].orderbyname.value=name; document.forms[0].orderdesc.value="desc"; } document.forms[0].submit(); } function create_form(){ var myLeft = (screen.width-650)/2; var myTop = (screen.height-250)/2; window.open("ServiceCallAction.do?reqCode=show_add","","height=400, width=800, ,top=" + myTop + ",left=" + myLeft+",toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no"); } function search_form(){ var status=document.forms[0].status.value; document.forms[0].submit(); } function del_spm(id){ if(confirm('<fmt:message key="fileManager.confirm.del" />')) { document.forms[0].action="ServiceCallAction.do?reqCode=deleteServiceCall&id="+id; search_form(); } } function update_spm(id){ var myLeft = (screen.width-650)/2; var myTop = (screen.height-250)/2; window.open("ServiceCallAction.do?reqCode=show_edit&id="+id,"","height=600, width=800, ,top=" + myTop + ",left=" + myLeft+",toolbar=no,scrollbars=2"); } function authorized_spm(id){ var myLeft = (screen.width-650)/2; var myTop = (screen.height-250)/2; alert("程序正在修改中。。。。"+id); // window.open("ServiceCallAction.do?reqCode=show_authorized&id="+id,"","height=500, width=300, ,top=" + myTop + ",left=" + myLeft+",toolbar=no,scrollbars=2"); } </script> <body style="margin-top:-8px;"> <div class="row" > <div class="row_table_top"> <div class="row_table_top_left"> <img src="${pageContext.request.contextPath}/images/point_down.gif" /><fmt:message key="sc.query"/></div> </div> <div class="row_table_middle" id="tab1" > <html:form action="/ServiceCallAction.do?reqCode=showIndex" method="post" styleClass="FORM"> <html:hidden property="orderbyname" value="${orderbyname}"/> <html:hidden property="orderdesc" value="${orderdesc}"/> <html:hidden property="reqCode" value="showIndex"/> <div class="boxform"> <ul> <li style="width:100%;padding-left:10px;"> <fmt:message key="sc.type"/> <html:select property="status" style="width:145" value="${status}"> <html:option value="">全部</html:option> <html:option value="">新建</html:option> <html:option value="">处理中</html:option> <html:option value="">待确认</html:option> <html:option value="">已关闭</html:option> <%--<html:optionsCollection name="1" value="id" label="name"/> --%> </html:select> <html:button styleClass="button" property="search" onclick="search_form()"> <fmt:message key='spm.list.select'/> </html:button> <html:button styleClass="button" property="create" onclick="create_form()"> <fmt:message key='spm.list.add'/> </html:button> </li> </ul> </div> <div class="row_paging" style="background:none;border:none"> <jsp:include page="../page.jsp"/> <script language="javascript"> pageSetForm(document.forms[0]); </script> </div> <table class="table3" cellpadding="0" cellspacing="0"> <tr> <td> <table class="table3_1" cellpadding="0" cellspacing="0"> <tr> <th> <fmt:message key="spm.list.numbers"/> </th> <th> <fmt:message key="sc.list.name"/> </a> </th> <th> <a href="#" onclick=""> <b><fmt:message key="sc.type" /></b> </a> <c:if test="${orderbyname=='status'}"> <c:if test="${orderdesc=='desc'}"> <img src="${pageContext.request.contextPath}/images/pxdown.gif" id=" " width="9" height="9" border="0" /> </c:if> <c:if test="${orderdesc==''}"> <img src="${pageContext.request.contextPath}/images/pxup.gif" id=" " width="9" height="9" border="0" /> </c:if> </c:if> </th> <th> <a href="#" onclick=""> <b><fmt:message key="sc.create.name" /></b> <c:if test="${orderbyname=='creator'}"> <c:if test="${orderdesc=='desc'}"> <img src="${pageContext.request.contextPath}/images/pxdown.gif" id=" " width="9" height="9" border="0" /> </c:if> <c:if test="${orderdesc==''}"> <img src="${pageContext.request.contextPath}/images/pxup.gif" id=" " width="9" height="9" border="0" /> </c:if> </c:if> </th> <th> <a href="#" onclick="orderby('create_time');"> <b><fmt:message key="spm.list.creatTime" /></b> </a> <c:if test="${orderbyname=='create_time'}"> <c:if test="${orderdesc=='desc'}"> <img src="${pageContext.request.contextPath}/images/pxdown.gif" id=" " width="9" height="9" border="0" /> </c:if> <c:if test="${orderdesc==''}"> <img src="${pageContext.request.contextPath}/images/pxup.gif" id=" " width="9" height="9" border="0" /> </c:if> </c:if> </th> <th> <fmt:message key="spm.list.do"/> </th> </tr> <c:forEach var="servicec" items="${serviceCallList}" varStatus="status"> <c:if test="${status.count%2==0}"> <tr class="double"> </c:if> <c:if test="${status.count%2!=0}"> <tr> </c:if> <td>${status.count}</td> <td><div align="left">${servicec.subject} </div></td> <td style="text-align:left;"><div align="center">${servicec.status}</div></td> <td><div align="center"><span style="text-align:left;"> ${servicec.creator} </span></div></td> <td> <fmt:formatDate value="${servicec.create_time}" pattern="yyyy-MM-dd HH:mm:ss" /> </td> <td> <!-- 授权--> <a href="javascript:authorized_spm(${servicec.id})" title="<fmt:message key='doc.grant'/> "> <img src="${pageContext.request.contextPath}/images/ry.gif" /> </a> <!-- 修改--> <a href="javascript:update_spm(${servicec.id})" title="<fmt:message key="spm.list.update"/>"> <img src="${pageContext.request.contextPath}/images/rtop.gif" /> </a> <!-- 删除--> <a href="javascript:del_spm(${servicec.id})" title="<fmt:message key="spm.list.delet"/>"> <img src="${pageContext.request.contextPath}/images/delete.gif" /> </a> </td> </tr> </c:forEach> <c:if test="${countRecord == 0}"> <tr> <td colspan="7"> <font color="red"><fmt:message key="spm.list.no"/></font> </td> </tr> </c:if> </table></td> </tr> </table> </html:form> </div> </div> <%@ include file="../footer.jsp" %>
以上是一些分页的部分代码。。
相关推荐
"jsp+struts1分页"是一个经典的Java Web开发话题,它涉及到JSP(JavaServer Pages)和Struts1这两个核心技术。在这里,我们将深入探讨如何使用这两者实现一个高效的分页系统。 首先,让我们了解一下JSP。JSP是Java...
在Struts 1框架中实现分页,我们需要理解以下几个关键知识点: 1. **MVC架构**:Struts 1遵循MVC设计模式,将应用程序逻辑分为模型、视图和控制器三个部分。在分页场景中,模型负责处理数据,控制器处理用户请求并...
在探讨Struts2框架下的增删改查以及分页查询功能时,我们首先需要理解Struts2框架本身。Struts2是Apache软件基金会的一个开源Web应用框架,它继承了Struts1的一些特性,并在此基础上进行了大量的改进和扩展,提供了...
1. **创建Action类**:首先,你需要创建一个Action类,该类将处理用户的请求,包括获取数据、计算总页数以及处理分页参数。例如,你可以定义两个参数,`currentPage`和`pageSize`,用于跟踪当前页和每页显示的条目...
本资源通过Struts框架实现了分页功能,主要涉及到以下几个关键知识点: 1. **MVC设计模式**:MVC模式将应用程序分为三个核心部分:模型(Model)、视图(View)和控制器(Controller)。模型负责处理业务逻辑,视图...
Struts2分页源码技术是Web开发中一个重要的实践,尤其是在处理大数据量时,能够有效地提高用户体验,避免一次性加载过多数据导致页面响应慢。在本文中,我们将深入探讨Struts2分页技术的实现原理、应用方法以及与...
用Struts2+mysql实现的简单信息录入,分页查询
该文档详细描述了struts2版本的分页显示,值得一读
本文将详细介绍Struts2实现分页效果的第二种方法。 在Struts2中,实现分页通常涉及以下几个关键步骤: 1. **模型(Model)**:首先,我们需要一个实体类来存储待分页的数据,例如`User`。然后,创建一个`PageBean`类...
1. **创建Action类**:这是Struts2的核心组件,负责处理用户的请求。在Action类中,我们需要定义与分页相关的属性,如当前页数、每页显示的记录数以及总记录数等。同时,Action类需要包含处理分页请求的方法。 2. *...
1. **Action类**:在Struts2中,Action类是处理用户请求的中心。为了实现分页,我们需要创建一个包含分页参数(如当前页数、每页记录数)的Action类,并提供相应的业务逻辑。 2. **模型(Model)**:模型层负责与...
【hibernate+struts2分页代码】是关于如何在Java Web开发中结合Hibernate ORM框架和Struts2 MVC框架实现数据分页的功能。在Web应用程序中,分页是提高用户体验的重要手段,它允许用户逐步浏览大量数据,而无需一次性...
MyBatis增 删 改 查 struts2分页
本项目名为“jsp +struts 分页经典”,显然是一个利用这两种技术实现的分页展示数据的案例。下面我们将深入探讨JSP和Struts框架,以及它们在分页、查询和数据操作中的应用。 首先,JSP是Java平台上的动态网页技术,...
下面是我用Struts2做的一个分页显示实例,基本的思路是:把数据库表中的每一行数据封装成一个对象,用一个返回类型为List的方法返回这些对象,接着在Struts2的action里面定义一个List属性,用这个List来接收从数据库...
本教程将深入讲解如何在Struts1.2框架中实现分页功能。 一、理解分页原理 分页的基本思想是将数据库中的数据分割成若干个部分,每次只加载一部分到前端展示,用户可以通过点击页码或导航按钮来切换不同的数据页。...
1. 使用索引:确保用于排序和分页的字段有适当的数据库索引,以加快查询速度。 2. 数据库级别的分页:某些数据库系统提供了原生的分页功能,比如MySQL的LIMIT和OFFSET,这通常比在应用程序层面实现更有效率。 3. ...
### Struts2 实现分页及 `<s:bean>` 标签详解 #### 一、Struts2 分页概述 在 Java Web 开发中,为了提高用户体验并减轻服务器负担,通常采用分页技术来展示数据。Struts2 框架提供了一套强大的工具和标签库来帮助...
这是struts的一个练习 这是struts的一个练习这是struts的一个练习这是struts的一个练习