易截截图软件、单文件、免安装、纯绿色、仅160KB

纯JSP分页代码之Mysql

//运行图:
//连接字符串
String url="jdbc:mysql://localhost/"+dbName+"?user="+userName+"&password="+userPasswd;
Class.forName(driverName).newInstance();
Connection connection=DriverManager.getConnection(url);
Statement statement = connection.createStatement();
//每页显示记录数
int PageSize = 8;
int StartRow = 0; //开始显示记录的编号
int PageNo=0;//需要显示的页数
int CounterStart=0;//每页页码的初始值
int CounterEnd=0;//显示页码的最大值
int RecordCount=0;//总记录数;
int MaxPage=0;//总页数
int PrevStart=0;//前一页
int NextPage=0;//下一页
int LastRec=0;
int LastStartRecord=0;//最后一页开始显示记录的编号
//获取需要显示的页数,由用户提交
if(request.getParameter("PageNo")==null){ //如果为空,则表示第1页
  if(StartRow == 0){
     PageNo = StartRow + 1; //设定为1
  }
}else{
  PageNo = Integer.parseInt(request.getParameter("PageNo")); //获得用户提交的页数
  StartRow = (PageNo - 1) * PageSize; //获得开始显示的记录编号
}
//因为显示页码的数量是动态变化的,假如总共有一百页,则不可能同时显示100个链接。而是根据当前的页数显示
//一定数量的页面链接
//设置显示页码的初始值!!
  if(PageNo % PageSize == 0){
   CounterStart = PageNo - (PageSize - 1);
  }else{
   CounterStart = PageNo - (PageNo % PageSize) + 1;
  }
CounterEnd = CounterStart + (PageSize - 1);
%>
<html>
<head>
<title>分页显示记录</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<%
//获取总记录数
ResultSet rs = statement.executeQuery("select count(*) from items" );
rs.next();
RecordCount = rs.getInt(1);
rs = statement.executeQuery("SELECT image_url,author,price,item_id from items ORDER BY item_id DESC LIMIT "
       +StartRow+", "+PageSize);
//获取总页数
MaxPage = RecordCount % PageSize;
if(RecordCount % PageSize == 0){
  MaxPage = RecordCoun


相关文档:

jsp的session详解


http://www.egzcn.com/article/webbc/JSP/2006-03-22/2003.html 来源
摘要:虽然session机制在web应用程序中被采用已经很长时间了,但是仍然有很多人不清楚session机制的本质,以至不能正确的应用这一技术。本文将详细讨论session的工作机制并且对在Java web application中应用session机制时常见的问题作 ......

在JSP里调用spring管理的bean取得数据


一:web.xml配置
<servlet>
<servlet-name>context</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<context-param>
<param-name>cont ......

jsp静态化和伪静态化


首先说说为什么要静态化。
对于现在的Web Application来说,动态页面是占有绝对高的地位的,正因为有了动态化,才有了现在Web的丰富多彩,但是如同所有别的事实一样,好处往往都是有代价的。
为了产生出动态的效果,每一次对页面的请求都会要求服务器对页面进行编译或者执行,这些操作都很消耗系统资源。如果这期间还有 ......

jsp学习笔记1

JSP(java server page)
JSP是服务器端运行的页面,JSP本事就是一个文档,他不仅可以包含静态的HTML代码,也可以包含动态的JAVA代码,服务器容器可以将JSP转换成Servlet发布,并接受请求。
Jsp文件只需放在应用文件下就可以了。
JSP例子:
     <html>
     <head& ......

JSP文章内容分页(JSP + JDBC)

表结构:
CREATE TABLE `article` (                              
           `id` int(10) unsigned ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号