如何用Jsp读取Mysql数据库

 1//说明count是总的记录的条数   
 2//page是用户提交的参数,用于控制分页的,允许的值是正整数,负整数   
 3int i=count/15; //总页,每页显示15条记录   
 4int j=i/10; //总的大页 ,没10个页面分一大页   
 5//Page 显示的页面   
 6int StartPage;   
 7//int HrefPage;   
 8if (Page<0) Page=0-Page*10; //10页分一次   
 9StartPage=Page/10; //10页分一次   
10out.print ("[共有"+i+"页]");   
11//out.print ("共有"+j+"屏");   
12//out.print ("显示第"+Page+"页");   
13//out.print ("StartPage="+StartPage);   
14if (StartPage>0)   
15out.print ("|

<a href='"connectmysql.jsp?page=-"+Integer.toString(StartPage-1)+""'>前10页</a>

1");   
2for (int k=0;k<10;k++)   
3{ int p=StartPage*10+k;   
4if (p>i) break;   
5if (p==Page)   
6out.print ("|第"+Integer.toString(p+1)+"页");   
7else   
8out.print ("|

<a href='"connectmysql.jsp?page="+p+""'>第"+Integer.toString(p+1)+"页</a>

1");   
2}   
3if (StartPage

<j) ("|<a="" href='"connectmysql.jsp?page=-"+Integer.toString(StartPage+1)+""' out.print="">后10页");
out.print ("|");

Published At
Categories with Web编程
Tagged with
comments powered by Disqus