jsp分页
源程序
<%String sConn="你的连接"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(sConn,"你的用户名","密码");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("select * from mytable_view");
String sqlcount="select count(*) from mytable_view";
ResultSet rscount=stmtcount.executeQuery(sqlcount);
int pageSize=你的每页显示纪录数;
int rowCount=0; //总的记录数
while (rscount
int pageCount; //总的页数
int currPage; //当前页数
String strPage;
strPage=request.getParameter("page");
if (strPage==null){
currPage=1;
}
else{
currPage=Integer.parseInt(strPage);
if (currPage<1) currPage=1;
}
pageCount=(rowCount+pageSize-1)/pageSize;
if (currPage>pageCount) currPage=pageCount;
int thepage=(currPage-1)*pageSize;
int n=0;
rs.absolute(thepage+1);
while (n<(pageSize)&&!rs
%>
<%rs.close();
rscount.close();
stmt.close();
stmtcount.close();
conn.close();
%>
//下面是 第几页等
<form name="sinfo" method="post" action="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>" onSubmit="return testform(this)">
第<%=currPage%>页 共<%=pageCount%>页 共<%=rowCount%>条
<%if(currPage>1){%><a href="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>">首页</a><%}%>
<%if(currPage>1){%><a href="sbinfo_index.jsp?page=<%=currPage-1%>&condition=<%=condition%>&type=<%=type%>">上一页</a><%}%>
<%if(currPage<pageCount){%><a href="sbinfo_index.jsp?page=<%=currPage+1%>&condition=<%=condition%>&type=<%=type%>">下一页</a><%}%>
<%if(pageCount>1){%><a href="sbinfo_index.jsp?page=&l
相关文档:
get
jsp url ${param.serialID}
action jsp String commentId = ServletActionContext.getRequest().getParameter("commentId");
-- ......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config.dtd">
<tiles-definitions>
<definition name="tscs.templet" path="/pa ......
<body>
<%
Cookie[] cookies = request.getCookies() ;
Cookie cookie = null ;
if(cookies!=null){
cookie = cookies[0] ;
out.print("上次访问的ip是: " + request.getRemoteAddr() +"<br>") ;&n ......
通过jsp(SUN企业级应用的首选)程序获得database里的数据,然后通过程序控制其显示方式,这种方式明显缺点是如果数据量比较大的时候会有明显的性能下降
现将测试代码奉上,尽管我尽量限制代码的长度
先说下开发步骤;DB脚本,测试获得的数据是否正确的显示在一个table中,添加那 ......