jsp分页显示完整实例

时间:2016.10.27 发布人:irgpz

jsp分页显示完整实例

已解决问题

谷歌irgpz用户在2016.10.27提交了关于“斩龙jsp分页显示完整实例”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2025-02-14T10:09:14。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,希望你能感受到,我最真诚的谢意 !

希望以下的回答,能够帮助你。

第1个回答

用户名:mgbem  

这篇文章主要介绍了jsp分页显示完整实例,以文章管理页面为例详细分析了jsp的分页显示实现技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了jsp分页显示的实现方法。分享给大家供大家参考。

具体实现方法如下:

代码如下:%@pagecontentType=text/html;charset排束映轻=gb2312langu岩松营侵车检宗约age=j**a来自import=j**a.sql.*errorPage=%
%@includefile=../inc/ChkPwd.jsp%
%@温志哪表验只重叶乡双includefile=../DB.jsp%
!DOCTYPEhtmlPUBLIC-//W3C//DTDXh**TML1.0Tra问答nsitional//ENhttp://www.w3.org/TR/xhtml1/DTD/xh克等激书坐相眼评站tml1-transit模白安倍鱼令几认扬造ional.dtd
htmlxmlns=http://www.w3.org/1999/xht年够全做字便席从衣北ml
head
metaname=robotscontent=noindex,nofollow/
metahttp-equiv=Con容势训孔飞凯四谓简担笔tent-Typecontent=text/html;c民间职巴说发例harset=gb2312/
title文章管理/title
linkhref=Style.cssrel=调感修议集院汽叶刚试stylesheettyp职才举e=text/css用片读/
/head
body

准抗存衡呼头故掉消tablewidth=98%height=77%border=0cellpadding=0cellspacing=0
trclass=STYLE1
tdwidth=100%height=26backg远婷果和太再功每翻妒round=images/admin_bg_1.gifstrongfo低把ntcolor=#FFFFFF--spanclass=ST编阳导轻记资守YLE1内容管理/span/子蒸误深氧造名利font/strong/td
/tr
tr
tdcolspan=10
/td
/tr

t以管全取必rclass=title
tdheight=25background=images/admin_bg_1.gifclass=t2|
%
Stringop;
StringID=request.getParameter(id);
op=request.getParameter(op);
if(op==**ll){
op=my;
}
if(op.equals(del)ID!=**ll){
Stringbbb=newString(request.getParameter(BigClassName).getBytes(iso8859_1));
Statementstmt_ChannelDEL=conn.createStatement();
StringSqldel=deletefromhl_newswhereid=+ID;
intshan=stmt_ChannelDEL.executeUpdate(Sqldel);
if(shan0)
{
out.print(scripttype=text/j**ascriptalert(已成功删除!);window.location.href='h**anye_Manages.jsp?BigClassName=+bbb+';/script);
}
stmt_ChannelDEL.close();
return;
}
StatementstmtA=conn.createStatement(ResultSet.TYPE_SCROLL_**NSITIVE,ResultSet.CONCUR_READ_ONLY);
StringSqlA=Select*fromhl_**allclassWh**EREbigname='行业新闻'orderbyidasc;
ResultSetRsA=stmtA.executeQuery(SqlA);
while(RsA.next()){

%
aclass='t2'href='h**anye_Manages.jsp?modi=新闻BigClassName=%=RsA.getString(**allname)%'%=RsA.getString(**allname)%/a|
%
}
RsA.close();//关闭记录集对象
stmtA.close();//关闭语句对象
%
/td
/tr

tr
tdheight=20/td
/tr
tr
tdalign=centervalign=topbgcolor=#ECF5FF

formname=form2action=list.asp?action=delallmodi=新闻method=post
tablewidth=100%cellpadding=3cellspacing=2bgcolor=#FFFFFFstyle=word-bre**:bre**-all
trclass=t2
tdwidth=32height=28align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1ID/td

tdwidth=80align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1新闻大类/td

tdwidth=88align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1新闻小类/td

tdwidth=291align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1style=word-bre**:bre**-all新闻标题/td

tdwidth=179align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1新闻图片/td

tdwidth=76align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1发布时间/td

tdwidth=64align=centerbackground=images/admin_bg_1.gifbgcolor=#**DAFFclass=STYLE1操作/td
/tr
%
intpageSize=10;//每页显示的文章数
intshowPage=1;//当前页面显示的页号
intrecCount=0;//ResultSet中的文章总数
intpageCount=0;//分页后的总页数
StringSqlArticle;
StringtoPage=request.getParameter(page);
Stringbgname=newString(request.getParameter(BigClassName).getBytes(iso8859_1));
Statementstmt_Article=conn.createStatement(ResultSet.TYPE_SCROLL_**NSITIVE,ResultSet.CONCUR_READ_ONLY);
SqlArticle=Select*fromhl_newswhere**allname='+bgname+'orderbyIDDESC;
ResultSetRsArticle=stmt_Article.executeQuery(SqlArticle);
if(RsArticle.next()){
RsArticle.last();//指针飞到最后
recCount=RsArticle.getRow();//去除最后一行的行号
pageCount=((recCount%pageSize)==0?(recCount/pageSize):(recCount/pageSize)+1);//得到一**可以分多少页
if(toPage!=**ll)
showPage=Integer.parseInt(toPage);
RsArticle.absolute((showPage-1)*pageSize+1);//跳到第showpage页的第一条
for(inti=1;i=pageSize;i++){
intNID=RsArticle.getInt(ID);
Stringimg=RsArticle.getString(img);
Stringttt=RsArticle.getString(times);
//ttt=ttt.substring(0,10);
%
trclass=STYLE1
tdwidth=32height=22align=centerbgcolor=#**DAFF%=NID%/td

tdalign=centerbgcolor=#**DAFF%=RsArticle.getString(bigname)%/td