欢迎来到天天文库
浏览记录
ID:16721054
大小:25.00 KB
页数:7页
时间:2018-08-24
《jsp过程中遇到的困难》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、1、分页用到的方法:PublicListfindListNews(intpage){Listlist=newArrayList();IntrowBegin=0;If(page>1){rowBegin=5*(page-1);}Stringsql="selecttop5*fromnewswhereidnotin(selecttop"+rowBegin+"idfromnews)";try{conn=this.getConn();pstmt=conn.prepareStatement(sql);rs=pstmt.executeQuery();while(rs.next()
2、){Newsnews=newNews();news.setContent(rs.getString("content"));news.setId(rs.getInt("id"));news.setModifytime(rs.getString("modifytime"));20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavin
3、gscertificate,certificatebondsapplyformortgageloans,acceptingonlythelendernews.setPulishtime(rs.getString("publishtime"));news.setTitle(rs.getString("title"));news.setUid(rs.getInt("uid"));list.add(news);注:对象中的所有列都必须要set出来,包括主键}}catch(SQLExceptione){e.printStackTrace();}returnlist;}一共
4、多少条的方法:publicintfindCountNews(){intcount=0;try{conn=this.getConn();Stringsql="selectcount(*)fromnews";pstmt=conn.prepareStatement(sql);rs=pstmt.executeQuery();while(rs.next()){20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsb
5、onds(electronic);3.notdrawnonabanksavingscertificate,certificatebondsapplyformortgageloans,acceptingonlythelendercount=rs.getInt(1);注:上面这行是固定的。}}catch(SQLExceptione){e.printStackTrace();}returncount;}一共多少页的方法:publicintfindCountPage(){intcounts=0;try{conn=this.getConn();Stringsql="sele
6、ctcount(*)fromnews";pstmt=conn.prepareStatement(sql);rs=pstmt.executeQuery();while(rs.next()){counts=rs.getInt(1);}20currencydeposit,weprescribeapassonaregularbasis,qilucardaccountonaregularbasis),certificatebondsandsavingsbonds(electronic);3.notdrawnonabanksavingscertificate,certific
7、atebondsapplyformortgageloans,acceptingonlythelender}catch(SQLExceptione){e.printStackTrace();}counts=counts%5==0?counts/5:counts/5+1;returncounts;}在JSP页面里写入:if(pages==null){pages="1";}intp=Integer.parseInt(pages);intcounts=newsdao.findCountPage();intcount=newsdao.findCountNews();8、ef="i
8、ef="i
此文档下载收益归作者所有