日期:2014-05-18  浏览次数:20745 次

跪求JSP分页代码,包括实例...
如上....

------解决方案--------------------
uppp
------解决方案--------------------
不是很难,自己试试写写
------解决方案--------------------
<%@ page contentType= "text/html; charset=GBK " %>
<%@ page import= "java.sql.* " %>

<%String url = "jdbc:oracle:thin:@192.168.1.13:1521:GSSHJDB ";
String user = "newbaissq ";
String password = "newbaissq ";
Connection conn = DriverManager.getConnection(url,user,password);
Statement stmt = conn.createStatement();
%>
<% String toptitle= "所有新闻 ";%>

<script> <%--选中一个值后,打开它所链接的页面--%>
function GoToWhere(s){
var d = s.options[s.selectedIndex].value;
window.location=d;
s.selectedIndex=0;
}
</script>

<div align= "center ">
<table width= "766 " align= "center ">
<% String colors;
String sqlname;
int intPageSize;
int intRowCount;
int intPageCount;
int intPage;
String strPage;
int i,j;
intPageSize=10;
strPage=request.getParameter( "page ");

if(strPage==null){
intPage=1;
}else{
intPage=Integer.parseInt(strPage);
if(intPage <1)
intPage=1;
}
sqlname= "select count(id) from scott.video order by times desc ";
ResultSet rt = stmt.executeQuery(sqlname);
rt.next();
intRowCount=rt.getInt(1);
intPageCount=(intRowCount+intPageSize-1)/intPageSize;
if(intPage> intPageCount)
intPage=intPageCount;
sqlname= "select * from scott.video order by times desc ";
ResultSet rs=stmt.executeQuery(sqlname);
i=(intPage-1)*intPageSize;
for(j=0;j <i;j++)
rs.next();
if(intRowCount==0){%>
对不起,此版块暂无内容!
<%}else{
i=0;
while (i <intPageSize && rs.next()){
if(i%2==0){
colors= "#ffffff ";
}else{
colors= "#d6e8e9 ";
}
%>
<tr bgcolor= " <%=colors%> ">
<td width= "4% ">
<div align= "center "> <img src= " ">
</div>
</td>
<td width= "96% " height= "20 "> <a href= "video.jsp?id= <%=rs.getString( "id ")%> ">
<%=rs.getString( "vdtitle ")%> </a>
</td>
</tr>
<% i++;}
}%>
<tr bgcolor= "#ffffff "> <td height=20 colspan=2>
<div align= "left ">
<p align= 'center ' vAlign= 'bottom '>
第 <%=intPage%> 页&nbsp;&nbsp;&nbsp;共 <%=intPageCount%> 页&nbsp;&nbsp;&nbsp;
<%if(intPage <intPageCount){%>
<a href= "listvedio.jsp?page= <%=intPage+1%> "> 下一页 </a> &nbsp;&nbsp;&nbsp;
<%}if(intPage> 1){%>
<a href= "listvedio.jsp?page= <%=intPage-1%> "> 上一页 </a> &nbsp;&nbsp;&nbsp;
<%}%>
</div>
<div align= "right "> <a href= 'javascript:window.close() '> [关闭窗口] </a> </div>
</tr>