jsp分页
源程序
<%String sConn="你的连接"
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection conn=DriverManager.getConnection(sConn,"你的用户名","密码");
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
Statement stmtcount=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
ResultSet rs=stmt.executeQuery("select * from mytable_view");
String sqlcount="select count(*) from mytable_view";
ResultSet rscount=stmtcount.executeQuery(sqlcount);
int pageSize=你的每页显示纪录数;
int rowCount=0; //总的记录数
while (rscount
int pageCount; //总的页数
int currPage; //当前页数
String strPage;
strPage=request.getParameter("page");
if (strPage==null){
currPage=1;
}
else{
currPage=Integer.parseInt(strPage);
if (currPage<1) currPage=1;
}
pageCount=(rowCount+pageSize-1)/pageSize;
if (currPage>pageCount) currPage=pageCount;
int thepage=(currPage-1)*pageSize;
int n=0;
rs.absolute(thepage+1);
while (n<(pageSize)&&!rs
%>
<%rs.close();
rscount.close();
stmt.close();
stmtcount.close();
conn.close();
%>
//下面是 第几页等
<form name="sinfo" method="post" action="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>" onSubmit="return testform(this)">
第<%=currPage%>页 共<%=pageCount%>页 共<%=rowCount%>条
<%if(currPage>1){%><a href="sbinfo_index.jsp?condition=<%=condition%>&type=<%=type%>">首页</a><%}%>
<%if(currPage>1){%><a href="sbinfo_index.jsp?page=<%=currPage-1%>&condition=<%=condition%>&type=<%=type%>">上一页</a><%}%>
<%if(currPage<pageCount){%><a href="sbinfo_index.jsp?page=<%=currPage+1%>&condition=<%=condition%>&type=<%=type%>">下一页</a><%}%>
<%if(pageCount>1){%><a href="sbinfo_index.jsp?page=&l
相关文档:
JSP同样是实现动态网页的一个利器。由于他的脚本语言是JAVA,所以继承了JAVA诸多优点。那么与ASP相比,应该可以说ASP和JSP基本不是一个档次上的。那么ASP.NET和JAVA却是可以抗衡的。
JSP和ASP相比较: 运行速度、运行开销、运行平台、扩展性、安全性、函数支持、厂商支持、对XML的支持等等,ASP都不是JSP的对手。COM ......
<body>
<%
Cookie[] cookies = request.getCookies() ;
Cookie cookie = null ;
if(cookies!=null){
cookie = cookies[0] ;
out.print("上次访问的ip是: " + request.getRemoteAddr() +"<br>") ;&n ......
乱码真是个令人讨厌的问题~
刚才终于把MySQL与JSP交互的乱码问题解决了。
办法如下:
1.在url处加上句子 "&useUnicode=true&characterEncoding=GBK" ;
2.我用Navicat Lite可视化工具创建MySQL数据库时,可选定数据库编码,也是 GBK ;
3.页面的编码可以选GBK以外的编码方式,如UTF-8。若操作页面的编码是UTF- ......
已经做好的一个J2EE项目,想应用flex中的图表,所以现在的首要问题就是如何把flex嵌入到jsp中,按照网上介绍的解决方案做了个小测试:
<%@ taglib uri="FlexTagLib" prefix="mm"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
&nbs ......