免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
最簡單的一個(gè)分頁思路

這個(gè)分頁思路適合于web中的各種分頁需要,不過只是最基本的

package com.netshop.tag;

import java.sql.ResultSet;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

import com.netshop.data.*;

public class shownews extends TagSupport {
/**
*
*/
private static final long serialVersionUID = 1L;
public int i=0;
@Override
public int doEndTag() throws JspException {
// TODO Auto-generated method stub
JspWriter out=pageContext.getOut();
HttpServletRequest request=(HttpServletRequest)pageContext.getRequest();
DataStore ds=DataStore.getInstance();
ResultSet rs=null;
String sql_count="select count(*) from news";
String sql="select * from news";
String tmp=null;
int count=0;//記錄總數(shù)
int page=0; //當(dāng)前要顯示的頁數(shù)
int total_page=0;//頁面總數(shù)
try{
count=ds.readCount(sql_count);
}
catch(Exception ex)
{
count=0;
}
total_page=count/6;//計(jì)算總頁面
try
{
rs=ds.read(sql); //讀取所有的記錄集
}
catch(Exception e)
{
rs=null;
}
try
{
tmp=(String)request.getParameter("page");//從request中讀取page參數(shù)
if(tmp==null)
page=0;
else
page=Integer.parseInt(tmp);
}
catch(Exception ex1)
{
page=0;
}

//輸出記錄
try
{
out.print("<table width=600 height=30 border=1 cellpadding=0 bordercolor=#0066FF>");
out.print("<tr align=center><td height=30>編號(hào)</td><td height=30>標(biāo)題</td><td height=30>刪除</td></tr>");
//重點(diǎn)
for(i=0;i<page*6;i++)
{
rs.next();
}
i=page*6;
int j=0;
while((rs!=null)&&(rs.next())&&(j<6))
{
String newsid=rs.getString(1);
String newstitle=rs.getString(2);
newstitle=new String(newstitle.getBytes("ISO-8859-1"),"UTF-8");
out.print("<tr align=center><td height=30>"+newsid+"</td>");
out.print("<td height=30>"+newstitle+"</td>");
out.print("<td height=30><a href=deletenews.jsp?id="+newsid+">刪除</a></td></tr>");
j++;
}
if(page>0)
{
out.print("<tr align=center><td height=30 colspan=3><a href=news_edit.jsp?page=0>首頁</a>");
out.print("<a href=news_edit.jsp?page="+(page-1)+">上一頁</a>");
}
else
{
out.print("<tr align=center><td height=30 colspan=3>首頁");
out.print("上一頁");
}
if(page<total_page)
{
out.print("<a href=news_edit.jsp?page="+(page+1)+">下一頁</a>");
out.print("<a href=news_edit.jsp?page="+total_page+">末頁</a></td></tr>");
}
else
{
out.print("下一頁");
out.print("末頁</td></tr>");
}
out.print("</table>");
}
catch(Exception e)
{

}
return super.doEndTag();
}
}


本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Jsp分頁實(shí)例
jsp 分頁 oracle數(shù)據(jù)庫
JSP連接MySQL5.1配置與使用
常用公共代碼二之分頁代碼的實(shí)現(xiàn)
jsp頁面顯示新聞.公告之類的上一篇下一篇(轉(zhuǎn)載)
用java,jsp和javascript寫的分頁及有下拉列表分頁的功能
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服