从后台传过一个LIST,页面上直接根据这个LIST进行翻页操作而无须借助外部类

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import = "javax.naming.*"%>
<%@ page import = "javax.sql.*" %>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.util.*" %>
<%@ page import = "java.io.*"%>
<%@ page import = "Login.Loginer"%>
<%@ page import = "principal.WorkBillDataBean"%>
<%@ page session = "true"%>
<%
if (session.getAttribute("loginer")==null){
response.sendRedirect("../err/nologerror.jsp");
}
%>
<%!
public String getStr(String str) {
try {
if(str == null) str = "";
String temp_p = str;
byte[] temp_t = temp_p.getBytes("ISO8859-1");
String temp = new String(temp_t);
return temp;
}catch (Exception ee) {
ee.printStackTrace();
}
return "";
}
%>




查询结果




<%
String strDiv = "
";
strDiv = strDiv + "";
strDiv = strDiv + "
";
strDiv = strDiv + "
    ";
strDiv = strDiv + "系统正在进行操作,可能需要几秒钟
    ";
strDiv = strDiv + "请您稍候......
";
out.print(strDiv);
out.print("");
%>
查询结果










<%!
int curPage=1;//当前是第几页
int maxPage=1;//共多少页
int maxRowCount=1;//共多少行
int rowsPerPage=10;//每页多少行
int jumpCount=0;//要跳过多少行
%>
<%
ArrayList al=(ArrayList)session.getAttribute("workbill");
maxRowCount=al.size();//最大行数
//求得共多少页
if(maxRowCount%rowsPerPage==0)
maxPage=maxRowCount/rowsPerPage;
else
maxPage=maxRowCount/rowsPerPage+1;
//得到跳转到第几页
if(request.getParameter("jumpPage")!=null&&!request.getParameter("jumpPage").equals(""))
{
curPage=Integer.parseInt(request.getParameter("jumpPage"));
}
%>
<%
//计算要跳过多少行
if(curPage!=1)
{
jumpCount=rowsPerPage*(curPage-1);
}
else
{
jumpCount=0;
}
String workBillId="";
String workBillTypeId="";
String workBillTypeName="";
String workBillName="";
String beginDay="";
String enDay="";
String statusIdResult="";
String statusNameResult="";
String workDataId="";
int i=0;
%>
<%
try{
for(int j=jumpCount;j {
if(j>maxRowCount-1)
break;
WorkBillDataBean wb=(WorkBillDataBean)al.get(j);
workBillId= wb.getWorkBillId();
workBillTypeId=wb.getWorkBillId();
workBillTypeName= wb.getWorkBillTypeName();
workBillName=wb.getWorkBillName();
beginDay=wb.getBeginDay();
enDay=wb.getEnDay();
statusIdResult=wb.getStatusIdResult();
statusNameResult=wb.getStatusNameResult();
workDataId=wb.getWorkDataId();
i++;
%>











<%}
}catch(Exception e){
out.print(e);
}
%>









工作票名 工作票类型 建立时间 完成时间 当前状态 详细情况
<%=workBillName%> <%=workBillTypeName%> <%=beginDay%> <%=enDay%> <%=statusNameResult%>





每页<%=rowsPerPage%>行
共<%=maxRowCount%>行
第<%=curPage%>页
共<%=maxPage%>页


<%if(curPage==1){out.print("首页 上一页");}else{%>
首页
上一页
<%}%>
<%if(curPage==maxPage){out.print("下一页 尾页");}else{%>
下一页
尾页
<%}%>
转到第



<%
out.print("");
out.flush();
%>


你可能感兴趣的:(JSP)