分页后异常 什么异常应该贴出来啊是 分页标签的错还是 Action里的 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 那个参数是正确的,他跟这个问题没关系嘿嘿 我也不知道该加什么参数,因为我执行的语句是“from UserClass”没有任何条件的 分页类:package xxxx.web.util;public class SplitPage { private int nowPageNum = 0; // 当前页数 private int maxResults = 0; // 每页最大记录数 private int firstResult = 0; // 从第条记录数开始 private int countResult = 0; //总记录数 private int totalPage = 0; //总页数 private String url = ""; //跳转地址 public int getNowPageNum() { return nowPageNum; } public void setNowPageNum(int nowPageNum) { this.nowPageNum = nowPageNum; } public int getMaxResults() { return maxResults; } public void setMaxResults(int maxResults) { this.maxResults = maxResults; } public int getFirstResult() { return firstResult; } public void setFirstResult(int firstResult) { this.firstResult = firstResult; } public void setUrl(String url) { this.url = url; } public String getUrl() { return this.url; } public int getCountResult() { return countResult; } public void setCountResult(int countResult) { this.countResult = countResult; } public int getTotalPage() { return totalPage; } public void setTotalPage(int totalPage) { this.totalPage = totalPage; } public String splitPage(SplitPage sp,String programPath) { StringBuffer sbStr = new StringBuffer(); sbStr.append("共"+sp.getTotalPage()+"页 "); if (sp.getNowPageNum() <= 1) { sbStr.append("首页<IMG SRC=\"" + programPath + "/images/splitpage/firstPage.gif\">");//首页 } else { sbStr.append("<A HREF=\"" + sp.getUrl()+ "page=1\">首页"+"<IMG SRC=\"" + programPath + "/images/splitpage/firstPage.gif\" width=\"14\" border=\"0px\" height=\"11\" >"+"</A>");//首页 } if (sp.getNowPageNum() <= 1) { sbStr.append(" 上一页<IMG SRC=\"" + programPath + "/images/splitpage/prePage.gif\" height=\"11\" border=\"0px\" align=\"absmiddle\">");//上一页 } else { sbStr.append(" <A HREF=\"" + sp.getUrl() + "page="); sbStr.append(sp.getNowPageNum() - 1); sbStr.append("\">上一页"+"<IMG SRC=\"" + programPath + "/images/splitpage/prePage.gif\" width=\"14\" height=\"11\" border=\"0px\" align=\"absmiddle\">"+"</A>");//上一页 } sbStr.append(" "+this.getSelect()); sbStr.append(" <IMG SRC=\"" + programPath + "/images/splitpage/go.gif\" align=\"absmiddle\" onclick=\"forward()\" style=\"cursor:hand;\">"); if (sp.getNowPageNum() >= sp.getTotalPage()) { sbStr.append(" 下一页<IMG SRC=\"" + programPath + "/images/splitpage/nextPage.gif\" width=\"14\" height=\"11\" border=\"0px\" align=\"absmiddle\">");//下一页 } else { sbStr.append(" <A HREF=\"" + sp.getUrl() + "page="); sbStr.append(sp.getNowPageNum() + 1); sbStr.append("\">"+"下一页<IMG SRC=\"" + programPath + "/images/splitpage/nextPage.gif\" width=\"14\" height=\"11\" border=\"0px\" align=\"absmiddle\">"+"</A>");//下一页 } if (sp.getNowPageNum() >= sp.getTotalPage()) { sbStr.append(" 尾页<IMG SRC=\"" + programPath + "/images/splitpage/endPage.gif\" width=\"14\" height=\"11\" border=\"0\" align=\"absmiddle\">");//尾页 } else { sbStr.append(" <A HREF=\"" + sp.getUrl() + "page="); sbStr.append(sp.getTotalPage()); sbStr.append("\">尾页"+"<IMG SRC=\"" + programPath + "/images/splitpage/endPage.gif\" width=\"14\" height=\"11\" border=\"0\" align=\"absmiddle\">"+"</A>");//尾页 } //sbStr.append("<script language=\"javascript\">function forward(){if (!(/^\\d+$/.test(pagebutton.value))){alert('请用数字!')};else if (pagebutton.value >"+this.totalPage+"){alert('该页不存在!');}else{window.location.href='"+sp.getUrl() + "page='"+"+pagebutton.value;}}</script>"); sbStr.append("<script language=\"javascript\">function forward(){if (!(/^\\d+$/.test(document.getElementById('pagebutton').value))){alert('请用数字!')};else if (document.getElementById('pagebutton').value >"+this.totalPage+"){alert('该页不存在!');}else{window.location.href='"+sp.getUrl() + "page='"+"+document.getElementById('pagebutton').value;}}</script>"); //sbStr.append("总记录数:" + sp.getCountResult() +"条"); return sbStr.toString(); } //生成框 private String getSelect(){ String str ="<input type=\"text\" id=\"pagebutton\" value=\""+this.getNowPageNum()+"\" onchange=\"forward()\" class=\"splitInput\">"; return str; } } dao:public List findAll(Date tdTimeB, Date tdTimeE, String tkPlate, String crName, Integer tdStatus, SplitPage sp) { try { StringBuffer sb = new StringBuffer(); sb.append("from BlTransportDispatchView b where 1=1 "); if (tdTimeB != null && !"".equals(tdTimeB) && tdTimeE != null && !"".equals(tdTimeE)) { sb.append(" and (b.tdTime >= :tdTimeB and b.tdTime <= :tdTimeE)"); } if (tkPlate != null && !"".equals(tkPlate)) { sb.append(" and b.tkPlate like :tkPlate"); } if (crName != null && !"".equals(crName)) { sb.append(" and b.crName like :crName"); } if(tdStatus!=-1){ sb.append(" and b.tdStatus = :tdStatus"); } sb.append(" order by b.tdTime,b.crName,b.tkPlate"); Session session = getHibernateTemplate().getSessionFactory().getCurrentSession(); Query q = session.createQuery(sb.toString()); Query qc = session.createQuery("select count(*) " + sb.toString()); if (tdTimeB != null && !"".equals(tdTimeB) && tdTimeE != null && !"".equals(tdTimeE)) { tdTimeB.setHours(0); tdTimeB.setMinutes(0); tdTimeB.setSeconds(0); tdTimeE.setHours(23); tdTimeE.setMinutes(59); tdTimeE.setSeconds(59); q.setTimestamp("tdTimeB", tdTimeB); q.setTimestamp("tdTimeE", tdTimeE); qc.setTimestamp("tdTimeB", tdTimeB); qc.setTimestamp("tdTimeE", tdTimeE); } if (tkPlate != null && !"".equals(tkPlate)) { q.setString("tkPlate", "%" + tkPlate + "%"); qc.setString("tkPlate", "%" + tkPlate + "%"); } if (crName != null && !"".equals(crName)) { q.setString("crName", "%" + crName + "%"); qc.setString("crName", "%" + crName + "%"); } if(tdStatus!=-1){ q.setInteger("tdStatus", tdStatus); qc.setInteger("tdStatus", tdStatus); } List lc = qc.list(); Iterator iter = lc.iterator(); Integer count = 0; while (iter.hasNext()) { count = (Integer) iter.next(); } sp.setCountResult(count);// 总记录数 sp.setTotalPage((count + sp.getMaxResults() - 1) / sp.getMaxResults());// 总页数 q.setFirstResult(sp.getFirstResult());// 分页开始记录数 q.setMaxResults(sp.getMaxResults());// 每页最大记录数 session.flush(); return q.list(); } catch (RuntimeException re) { throw re; } }actionpublic ActionForward toTDListPage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { String forward=request.getParameter("forward"); Integer tdStatus=TypeConvertUtil.strToInt(request.getParameter("tdStatus")); Date tdTimeB=DateUtil.toDate(request.getParameter("tdTimeB")); Date tdTimeE=DateUtil.toDate(request.getParameter("tdTimeE")); String tkPlate=request.getParameter("tkPlate"); String crName=request.getParameter("crName"); //分页设置 int nowPage=1;//当前页数 String strPage=request.getParameter("page"); if(strPage!=null && !strPage.equals("")){ nowPage=Integer.parseInt(strPage);//当前页数数据类型转换 } int maxResults=15;//每页显示最大记录数 SplitPage sp=new SplitPage(); sp.setNowPageNum(nowPage);//设置当前页数 sp.setMaxResults(maxResults);//设置每页最大记录数 sp.setFirstResult((nowPage-1)*maxResults);//设置从第条记录数开始 String path = request.getContextPath()+"/blTransportDispatch.do?action=toTDListPage&forward="+forward; if(tdTimeB!=null && !"".equals(tdTimeB)){ path=path+"&tdTimeB="+request.getParameter("tdTimeB"); } if(tdTimeE!=null && !"".equals(tdTimeE)){ path=path+"&tdTimeE="+request.getParameter("tdTimeE"); } if(tkPlate!=null && !"".equals(tkPlate)){ tkPlate=new String(tkPlate.getBytes("iso-8859-1"),"GBK"); path=path+"&tkPlate="+URLEncoder.encode(tkPlate,"GBK"); } if(crName!=null && !"".equals(crName)){ crName=new String(crName.getBytes("iso-8859-1"),"GBK"); path=path+"&crName="+URLEncoder.encode(crName,"GBK"); } path=path+"&"; sp.setUrl(path);//设置分页路径 List list=blTransportDispatchService.findAll(tdTimeB, tdTimeE, tkPlate, crName, tdStatus, sp); request.setAttribute("sp", sp.splitPage(sp, request.getContextPath())); request.setAttribute("list", list); request.setAttribute("tdTimeB", request.getParameter("tdTimeB")); request.setAttribute("tdTimeE", request.getParameter("tdTimeE")); request.setAttribute("tkPlate", tkPlate); request.setAttribute("crName", crName); return mapping.findForward(forward); } jsp<%@ page language="java" pageEncoding="GBK"%><%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%><%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%><%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %><%@ taglib uri="/WEB-INF/c.tld" prefix="c"%><%String path=request.getContextPath();String sp=(String)request.getAttribute("sp");%><html><head><title></title><link type="text/css" rel="stylesheet" href="<%=path %>/css/public.css" /><link type="text/css" rel="stylesheet" href="<%=path %>/common/calendar/calendar-green.css" /><script type="text/javascript" src="<%=path %>/common/calendar/calendar.js"></script><script type="text/javascript" src="<%=path %>/common/calendar/calendar-zh.js"></script><script type="text/javascript" src="<%=path %>/common/calendar/calendar-setup.js"></script><script type="text/javascript" src="<%=path %>/js/sortableTable.js"></script><script type="text/javascript" src="<%=path %>/js/public.js"></script></head><body><form method="get" action="<%=path %>/blTransportDispatch.do"> <input type="hidden" name="action" value="toTDListPage"> <input type="hidden" name="forward" value="toTDLookListPage"> <input type="hidden" name="tdStatus" value="1"> <table class="table_top_search" width="100%" align="center"> <tr> <td class="table_top_search"><img src="<%=path %>/images/title_front.gif" width="15" height="15"> 调度查看 <img src="<%=path %>/images/button/showHideCnd.gif" width="16" height="16" onClick="showDiv('search')" style="cursor:pointer;"> <span id="mes" onClick="showDiv('search')" style="cursor:pointer;">隐藏条件</span></td> </tr> </table> <br> <div id="search"> <table class="table_public" width="100%" align="center"> <tr> <td rowspan="2" align="right" class="td_public">调度日期:</td> <td class="td_public">从 <input type="text" name="tdTimeB" id="tdTimeB" value="${requestScope.tdTimeB }"> <img src="<%=path %>/common/calendar/images/button.gif" id="tdTimeB_button" style="cursor: pointer; border: 1px solid red;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''" /></td> <td align="right" class="td_public">车牌号:</td> <td class="td_public"><input type="text" name="tkPlate" id="tkPlate" value="${requestScope.tkPlate }"></td> <td rowspan="2" align="center" class="td_public"><input type="submit" class="wsbutton" value="查 询" onMouseOver="this.className='wsbutton_hover'" onMouseOut="this.className='wsbutton'"></td> </tr> <tr> <td class="td_public">到 <input type="text" name="tdTimeE" id="tdTimeE" value="${requestScope.tdTimeE }"> <img src="<%=path %>/common/calendar/images/button.gif" id="tdTimeE_button" style="cursor: pointer; border: 1px solid red;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''" /></td> <td align="right" class="td_public">承运商:</td> <td class="td_public"><input type="text" name="crName" id="crName" value="${requestScope.crName }"></td> </tr> </table> </div></form><table id="mytable" class="table_public" width="100%" align="center" sort="1"> <thead> <tr> <th style="cursor:pointer" sorttype="Number">序号</th> <th style="cursor:pointer" sorttype="String">车牌号</th> <th style="cursor:pointer" sorttype="String">承运商</th> <th style="cursor:pointer" sorttype="Number">货值</th> <th style="cursor:pointer" sorttype="Number">数量</th> <th style="cursor:pointer" sorttype="Number">重量</th> <th style="cursor:pointer" sorttype="Number">体积</th> <th style="cursor:pointer" sorttype="Date">调度时间</th> <th style="cursor:pointer" sorttype="String">状态</th> <th>修改</th> <th>删除</th> </tr> </thead> <tbody> <c:forEach var="list" items="${requestScope.list}" varStatus="i"> <tr align="center" <c:if test="${i.index%2==0}">class="off1"</c:if><c:if test="${i.index%2==1}">class="off2"</c:if> onMouseOver="this.className='up'"<c:if test="${i.index%2==0}"> onMouseOut="this.className='off1'"</c:if><c:if test="${i.index%2==1}"> onMouseOut="this.className='off2'"</c:if>> <td class="td_public">${i.index+1 }</td> <td class="td_public">${list.tkPlate }</td> <td class="td_public">${list.crName }</td> <td class="td_public">${list.doGoodsValue }</td> <td class="td_public">${list.doGoodsNum }</td> <td class="td_public">${list.doGoodsWeight }</td> <td class="td_public">${list.doGoodsVol }</td> <td class="td_public">${list.tdTime }</td> <td class="td_public"> <c:if test="${list.tdStatus==1 }">已调车</c:if> <c:if test="${list.tdStatus==2 }">已添合同</c:if> </td> <td class="td_public"><a href=""><img src="<%=path %>/images/button/edit.gif" width="16" height="16" border="0"></a></td> <td class="td_public"><a href="#"><img src="<%=path %>/images/button/delete.gif" width="16" height="16" border="0"></a></td> </tr> </c:forEach> </tbody> <tr> <td colspan="3"><input type="button" class="wsbutton" value="返 回" onMouseOver="this.className='wsbutton_hover'" onMouseOut="this.className='wsbutton'" onClick="javascript:window.history.go(-1);"> </td> <td colspan="8" height="30" align="right"><%=sp%></td> </tr></table><script type="text/javascript">Calendar.setup({ inputField : "tdTimeB", ifFormat : "%Y-%m-%d", button : "tdTimeB_button", align : "Tl", singleClick : true});Calendar.setup({ inputField : "tdTimeE", ifFormat : "%Y-%m-%d", button : "tdTimeE_button", align : "Tl", singleClick : true});</script></body></html> 呵呵 搞定了哎 没想到是分页惹的祸啊,我的userclass查询的时候也使用的分页,那么在第二页的时候查的userclass就是第11-20的记录了,所以就没值哈谢谢佳娃和咖啡哈哈哈 咖啡的分页确实不错 JTable 表头 合并 如何实现点击图片变大 Hibernate,org.hibernate.QueryException 关于OA系统 请教一下插入oracle中字符为?问题 如何配置LOG4J 恳切请教:在rose中如何表示用例的扩展点阿??? 大家好!我是新来的!麻烦各位高手帮我解答一下好吗?谢谢了. 关于<s:debug/> 关于Struts2 Dispatcher分发器的线程安全问题 MyEclipse无法创建数据库表的映射文件 java编程
嘿嘿 我也不知道该加什么参数,因为我执行的语句是“from UserClass”没有任何条件的
private int nowPageNum = 0; // 当前页数 private int maxResults = 0; // 每页最大记录数 private int firstResult = 0; // 从第条记录数开始
private int countResult = 0; //总记录数
private int totalPage = 0; //总页数
private String url = ""; //跳转地址 public int getNowPageNum() {
return nowPageNum;
} public void setNowPageNum(int nowPageNum) {
this.nowPageNum = nowPageNum;
} public int getMaxResults() {
return maxResults;
} public void setMaxResults(int maxResults) {
this.maxResults = maxResults;
}
public int getFirstResult() {
return firstResult;
} public void setFirstResult(int firstResult) {
this.firstResult = firstResult;
}
public void setUrl(String url) {
this.url = url;
} public String getUrl() {
return this.url;
}
public int getCountResult() {
return countResult;
} public void setCountResult(int countResult) {
this.countResult = countResult;
}
public int getTotalPage() {
return totalPage;
} public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public String splitPage(SplitPage sp,String programPath) {
StringBuffer sbStr = new StringBuffer();
sbStr.append("共"+sp.getTotalPage()+"页 ");
if (sp.getNowPageNum() <= 1) {
sbStr.append("首页<IMG SRC=\"" + programPath
+ "/images/splitpage/firstPage.gif\">");//首页
} else {
sbStr.append("<A HREF=\"" + sp.getUrl()+ "page=1\">首页"+"<IMG SRC=\"" + programPath
+ "/images/splitpage/firstPage.gif\" width=\"14\" border=\"0px\" height=\"11\" >"+"</A>");//首页
} if (sp.getNowPageNum() <= 1) {
sbStr.append(" 上一页<IMG SRC=\"" + programPath
+ "/images/splitpage/prePage.gif\" height=\"11\" border=\"0px\" align=\"absmiddle\">");//上一页
} else {
sbStr.append(" <A HREF=\"" + sp.getUrl() + "page=");
sbStr.append(sp.getNowPageNum() - 1);
sbStr.append("\">上一页"+"<IMG SRC=\"" + programPath
+ "/images/splitpage/prePage.gif\" width=\"14\" height=\"11\" border=\"0px\" align=\"absmiddle\">"+"</A>");//上一页
} sbStr.append(" "+this.getSelect());
sbStr.append(" <IMG SRC=\"" + programPath
+ "/images/splitpage/go.gif\" align=\"absmiddle\" onclick=\"forward()\" style=\"cursor:hand;\">"); if (sp.getNowPageNum() >= sp.getTotalPage()) {
sbStr.append(" 下一页<IMG SRC=\"" + programPath
+ "/images/splitpage/nextPage.gif\" width=\"14\" height=\"11\" border=\"0px\" align=\"absmiddle\">");//下一页
} else {
sbStr.append(" <A HREF=\"" + sp.getUrl() + "page=");
sbStr.append(sp.getNowPageNum() + 1);
sbStr.append("\">"+"下一页<IMG SRC=\"" + programPath
+ "/images/splitpage/nextPage.gif\" width=\"14\" height=\"11\" border=\"0px\" align=\"absmiddle\">"+"</A>");//下一页
} if (sp.getNowPageNum() >= sp.getTotalPage()) {
sbStr.append(" 尾页<IMG SRC=\"" + programPath
+ "/images/splitpage/endPage.gif\" width=\"14\" height=\"11\" border=\"0\" align=\"absmiddle\">");//尾页
} else {
sbStr.append(" <A HREF=\"" + sp.getUrl() + "page=");
sbStr.append(sp.getTotalPage());
sbStr.append("\">尾页"+"<IMG SRC=\"" + programPath
+ "/images/splitpage/endPage.gif\" width=\"14\" height=\"11\" border=\"0\" align=\"absmiddle\">"+"</A>");//尾页
}
//sbStr.append("<script language=\"javascript\">function forward(){if (!(/^\\d+$/.test(pagebutton.value))){alert('请用数字!')};else if (pagebutton.value >"+this.totalPage+"){alert('该页不存在!');}else{window.location.href='"+sp.getUrl() + "page='"+"+pagebutton.value;}}</script>");
sbStr.append("<script language=\"javascript\">function forward(){if (!(/^\\d+$/.test(document.getElementById('pagebutton').value))){alert('请用数字!')};else if (document.getElementById('pagebutton').value >"+this.totalPage+"){alert('该页不存在!');}else{window.location.href='"+sp.getUrl() + "page='"+"+document.getElementById('pagebutton').value;}}</script>");
//sbStr.append("总记录数:" + sp.getCountResult() +"条");
return sbStr.toString();
}
//生成框
private String getSelect(){
String str ="<input type=\"text\" id=\"pagebutton\" value=\""+this.getNowPageNum()+"\" onchange=\"forward()\" class=\"splitInput\">";
return str;
}
}
String crName, Integer tdStatus, SplitPage sp) {
try {
StringBuffer sb = new StringBuffer();
sb.append("from BlTransportDispatchView b where 1=1 ");
if (tdTimeB != null && !"".equals(tdTimeB) && tdTimeE != null && !"".equals(tdTimeE)) {
sb.append(" and (b.tdTime >= :tdTimeB and b.tdTime <= :tdTimeE)");
}
if (tkPlate != null && !"".equals(tkPlate)) {
sb.append(" and b.tkPlate like :tkPlate");
}
if (crName != null && !"".equals(crName)) {
sb.append(" and b.crName like :crName");
}
if(tdStatus!=-1){
sb.append(" and b.tdStatus = :tdStatus");
}
sb.append(" order by b.tdTime,b.crName,b.tkPlate");
Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
Query q = session.createQuery(sb.toString());
Query qc = session.createQuery("select count(*) " + sb.toString());
if (tdTimeB != null && !"".equals(tdTimeB) && tdTimeE != null && !"".equals(tdTimeE)) {
tdTimeB.setHours(0);
tdTimeB.setMinutes(0);
tdTimeB.setSeconds(0);
tdTimeE.setHours(23);
tdTimeE.setMinutes(59);
tdTimeE.setSeconds(59);
q.setTimestamp("tdTimeB", tdTimeB);
q.setTimestamp("tdTimeE", tdTimeE);
qc.setTimestamp("tdTimeB", tdTimeB);
qc.setTimestamp("tdTimeE", tdTimeE);
}
if (tkPlate != null && !"".equals(tkPlate)) {
q.setString("tkPlate", "%" + tkPlate + "%");
qc.setString("tkPlate", "%" + tkPlate + "%");
}
if (crName != null && !"".equals(crName)) {
q.setString("crName", "%" + crName + "%");
qc.setString("crName", "%" + crName + "%");
}
if(tdStatus!=-1){
q.setInteger("tdStatus", tdStatus);
qc.setInteger("tdStatus", tdStatus);
}
List lc = qc.list();
Iterator iter = lc.iterator();
Integer count = 0;
while (iter.hasNext()) {
count = (Integer) iter.next();
}
sp.setCountResult(count);// 总记录数
sp.setTotalPage((count + sp.getMaxResults() - 1) / sp.getMaxResults());// 总页数
q.setFirstResult(sp.getFirstResult());// 分页开始记录数
q.setMaxResults(sp.getMaxResults());// 每页最大记录数
session.flush();
return q.list();
} catch (RuntimeException re) {
throw re;
}
}
actionpublic ActionForward toTDListPage(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
String forward=request.getParameter("forward");
Integer tdStatus=TypeConvertUtil.strToInt(request.getParameter("tdStatus"));
Date tdTimeB=DateUtil.toDate(request.getParameter("tdTimeB"));
Date tdTimeE=DateUtil.toDate(request.getParameter("tdTimeE"));
String tkPlate=request.getParameter("tkPlate");
String crName=request.getParameter("crName");
//分页设置
int nowPage=1;//当前页数
String strPage=request.getParameter("page");
if(strPage!=null && !strPage.equals("")){
nowPage=Integer.parseInt(strPage);//当前页数数据类型转换
}
int maxResults=15;//每页显示最大记录数
SplitPage sp=new SplitPage();
sp.setNowPageNum(nowPage);//设置当前页数
sp.setMaxResults(maxResults);//设置每页最大记录数
sp.setFirstResult((nowPage-1)*maxResults);//设置从第条记录数开始
String path = request.getContextPath()+"/blTransportDispatch.do?action=toTDListPage&forward="+forward;
if(tdTimeB!=null && !"".equals(tdTimeB)){
path=path+"&tdTimeB="+request.getParameter("tdTimeB");
}
if(tdTimeE!=null && !"".equals(tdTimeE)){
path=path+"&tdTimeE="+request.getParameter("tdTimeE");
}
if(tkPlate!=null && !"".equals(tkPlate)){
tkPlate=new String(tkPlate.getBytes("iso-8859-1"),"GBK");
path=path+"&tkPlate="+URLEncoder.encode(tkPlate,"GBK");
}
if(crName!=null && !"".equals(crName)){
crName=new String(crName.getBytes("iso-8859-1"),"GBK");
path=path+"&crName="+URLEncoder.encode(crName,"GBK");
}
path=path+"&";
sp.setUrl(path);//设置分页路径
List list=blTransportDispatchService.findAll(tdTimeB, tdTimeE, tkPlate, crName, tdStatus, sp);
request.setAttribute("sp", sp.splitPage(sp, request.getContextPath()));
request.setAttribute("list", list);
request.setAttribute("tdTimeB", request.getParameter("tdTimeB"));
request.setAttribute("tdTimeE", request.getParameter("tdTimeE"));
request.setAttribute("tkPlate", tkPlate);
request.setAttribute("crName", crName);
return mapping.findForward(forward);
}
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html"%>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic"%>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c"%>
<%
String path=request.getContextPath();
String sp=(String)request.getAttribute("sp");
%>
<html>
<head>
<title></title>
<link type="text/css" rel="stylesheet" href="<%=path %>/css/public.css" />
<link type="text/css" rel="stylesheet" href="<%=path %>/common/calendar/calendar-green.css" />
<script type="text/javascript" src="<%=path %>/common/calendar/calendar.js"></script>
<script type="text/javascript" src="<%=path %>/common/calendar/calendar-zh.js"></script>
<script type="text/javascript" src="<%=path %>/common/calendar/calendar-setup.js"></script>
<script type="text/javascript" src="<%=path %>/js/sortableTable.js"></script>
<script type="text/javascript" src="<%=path %>/js/public.js"></script>
</head>
<body>
<form method="get" action="<%=path %>/blTransportDispatch.do">
<input type="hidden" name="action" value="toTDListPage">
<input type="hidden" name="forward" value="toTDLookListPage">
<input type="hidden" name="tdStatus" value="1">
<table class="table_top_search" width="100%" align="center">
<tr>
<td class="table_top_search"><img src="<%=path %>/images/title_front.gif" width="15" height="15"> 调度查看 <img src="<%=path %>/images/button/showHideCnd.gif" width="16" height="16" onClick="showDiv('search')" style="cursor:pointer;"> <span id="mes" onClick="showDiv('search')" style="cursor:pointer;">隐藏条件</span></td>
</tr>
</table>
<br>
<div id="search">
<table class="table_public" width="100%" align="center">
<tr>
<td rowspan="2" align="right" class="td_public">调度日期:</td>
<td class="td_public">从
<input type="text" name="tdTimeB" id="tdTimeB" value="${requestScope.tdTimeB }">
<img src="<%=path %>/common/calendar/images/button.gif" id="tdTimeB_button" style="cursor: pointer; border: 1px solid red;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''" /></td>
<td align="right" class="td_public">车牌号:</td>
<td class="td_public"><input type="text" name="tkPlate" id="tkPlate" value="${requestScope.tkPlate }"></td>
<td rowspan="2" align="center" class="td_public"><input type="submit" class="wsbutton" value="查 询" onMouseOver="this.className='wsbutton_hover'" onMouseOut="this.className='wsbutton'"></td>
</tr>
<tr>
<td class="td_public">到
<input type="text" name="tdTimeE" id="tdTimeE" value="${requestScope.tdTimeE }">
<img src="<%=path %>/common/calendar/images/button.gif" id="tdTimeE_button" style="cursor: pointer; border: 1px solid red;" title="Date selector" onMouseOver="this.style.background='red';" onMouseOut="this.style.background=''" /></td>
<td align="right" class="td_public">承运商:</td>
<td class="td_public"><input type="text" name="crName" id="crName" value="${requestScope.crName }"></td>
</tr>
</table>
</div>
</form>
<table id="mytable" class="table_public" width="100%" align="center" sort="1">
<thead>
<tr>
<th style="cursor:pointer" sorttype="Number">序号</th>
<th style="cursor:pointer" sorttype="String">车牌号</th>
<th style="cursor:pointer" sorttype="String">承运商</th>
<th style="cursor:pointer" sorttype="Number">货值</th>
<th style="cursor:pointer" sorttype="Number">数量</th>
<th style="cursor:pointer" sorttype="Number">重量</th>
<th style="cursor:pointer" sorttype="Number">体积</th>
<th style="cursor:pointer" sorttype="Date">调度时间</th>
<th style="cursor:pointer" sorttype="String">状态</th>
<th>修改</th>
<th>删除</th>
</tr>
</thead>
<tbody>
<c:forEach var="list" items="${requestScope.list}" varStatus="i">
<tr align="center" <c:if test="${i.index%2==0}">class="off1"</c:if><c:if test="${i.index%2==1}">class="off2"</c:if> onMouseOver="this.className='up'"<c:if test="${i.index%2==0}"> onMouseOut="this.className='off1'"</c:if><c:if test="${i.index%2==1}"> onMouseOut="this.className='off2'"</c:if>>
<td class="td_public">${i.index+1 }</td>
<td class="td_public">${list.tkPlate }</td>
<td class="td_public">${list.crName }</td>
<td class="td_public">${list.doGoodsValue }</td>
<td class="td_public">${list.doGoodsNum }</td>
<td class="td_public">${list.doGoodsWeight }</td>
<td class="td_public">${list.doGoodsVol }</td>
<td class="td_public">${list.tdTime }</td>
<td class="td_public">
<c:if test="${list.tdStatus==1 }">已调车</c:if>
<c:if test="${list.tdStatus==2 }">已添合同</c:if>
</td>
<td class="td_public"><a href=""><img src="<%=path %>/images/button/edit.gif" width="16" height="16" border="0"></a></td>
<td class="td_public"><a href="#"><img src="<%=path %>/images/button/delete.gif" width="16" height="16" border="0"></a></td>
</tr>
</c:forEach>
</tbody>
<tr>
<td colspan="3"><input type="button" class="wsbutton" value="返 回" onMouseOver="this.className='wsbutton_hover'" onMouseOut="this.className='wsbutton'" onClick="javascript:window.history.go(-1);">
</td>
<td colspan="8" height="30" align="right"><%=sp%></td>
</tr>
</table>
<script type="text/javascript">
Calendar.setup({
inputField : "tdTimeB",
ifFormat : "%Y-%m-%d",
button : "tdTimeB_button",
align : "Tl",
singleClick : true
});
Calendar.setup({
inputField : "tdTimeE",
ifFormat : "%Y-%m-%d",
button : "tdTimeE_button",
align : "Tl",
singleClick : true
});
</script>
</body>
</html>
哎 没想到是分页惹的祸啊,
我的userclass查询的时候也使用的分页,那么在第二页的时候查的userclass就是第11-20的记录了,所以就没值哈
谢谢佳娃和咖啡哈
哈哈 咖啡的分页确实不错