小弟初学JAVA,想学习分页

bear_liu01 2009-11-09 09:11:43
小弟初学JAVA,想学习分页,谁能给个struts+jdbc+mysql的分页源码,最好有注释!
...全文
232 22 打赏 收藏 转发到动态 举报
写回复
用AI写文章
22 条回复
切换为时间正序
请发表友善的回复…
发表回复
icoveryou 2009-11-15
  • 打赏
  • 举报
回复
试试看pager-taglib框架 分析一下源码和文档
robyjeffding 2009-11-10
  • 打赏
  • 举报
回复
你用hibernate,有自带的分页处理
suwanjun881011 2009-11-10
  • 打赏
  • 举报
回复
google displaytag
不善^ 2009-11-10
  • 打赏
  • 举报
回复
百度上多的很 自己搜下吧
howsun_zh 2009-11-10
  • 打赏
  • 举报
回复
两个字母搞定J2EE通用分页,SSH构架全套代码:
http://howsun.blog.sohu.com/90707791.html
tomdoglz 2009-11-10
  • 打赏
  • 举报
回复
留个脚印
sangshusen_1988 2009-11-10
  • 打赏
  • 举报
回复
limit 0, 10
wanghailong0115 2009-11-10
  • 打赏
  • 举报
回复
去百度,Google搜下吧
steel1985 2009-11-10
  • 打赏
  • 举报
回复
jdbc主要是数据库分页,hibernate框架有自带的分页处理
这种东西网上老多的
97095639 2009-11-10
  • 打赏
  • 举报
回复
分页有很多,建议楼主去看看springside3 的分页
hao1314 2009-11-10
  • 打赏
  • 举报
回复
多样化
pzr131452 2009-11-10
  • 打赏
  • 举报
回复
分页最好是用spring
Defonds 2009-11-10
  • 打赏
  • 举报
回复
我的资源里有个 jsp+javabean分页源码,注释的相当详细,下载后即可使用
分页有N多种方案:模板、分页标签。。。我上传的这个属于很大众化的那种:分页javabean方案
楼主下载后可以自行修改成 struts+jdbc+mysql。分页在于思想,不在于框架限制

mengshan1986 2009-11-10
  • 打赏
  • 举报
回复
实际使用可以用hibernate分页的。
[code=Java][
Criteria criteria=session.createCriteria(Usertable.class);
criteria.addOrder(Order.asc("uid"));
criteria.setFirstResult((page-1)*pagesize);
criteria.setMaxResults(pagesize);
List list=criteria.list();
/code]
赤鬼007 2009-11-10
  • 打赏
  • 举报
回复
我也在关注这个问题
F_F_B_M 2009-11-10
  • 打赏
  • 举报
回复
对啊就是给初学者的啊!
什么都不能 2009-11-10
  • 打赏
  • 举报
回复
[Quote=引用 16 楼 f_f_b_m 的回复:]
<%
      request.setCharacterEncoding("utf-8");
      response.setHeader("gbk","utf-8");
        Connection con;
        Statement stm;
     
        ResultSet rs;
        try{
          Class.forName("com.mysql.jdbc.Driver");
        }catch(Exception e)
        {
          e.printStackTrace();
        }
        try{
       
        con=DriverManager.getConnection("jdbc:mysql://localhost:3306/lipin_db?useUnicode=true&characterEncoding=utf-8","root","root");
        stm=con.createStatement();
       
        String sqlString="select * from lipin1 where type=1";
        rs=stm.executeQuery(sqlString);
       
       
       
          int pageSize = 2;//定义每页显示的记录数; 
int pageCount; //定义分页后总页数变量
int nowPage; //定义当前页变量
int rowCount; //定义数据库中记录总条数变量
int nowRow;//定义当前记录行号变量
rs.last();
rowCount = rs.getRow();//获取数据库中记录总条数
String strPage = request.getParameter("page");//获取地址栏page变量的值

if (rowCount % pageSize == 0) {
pageCount = rowCount / pageSize;
} else {
pageCount = (rowCount / pageSize) + 1;
}//计算分页后总页数

if (strPage == null || strPage == "") {
nowPage = 1;
} //如果地址栏没有page变量或page变量值为空,则默认为第一页
else {
nowPage = Integer.parseInt(strPage);
}

if (nowPage < 1) {
nowPage = 1;
} else if (nowPage > pageCount) {
nowPage = pageCount;
}

nowRow = (nowPage * pageSize - (pageSize - 1));
rs.absolute(nowRow); //将指针定位到指定的记录行行号
        %>
        <table width="270" border="0">
  <tr>
    <td width="264"> <font size="1">您的位置:首页>鲜花 </font> </td>
  </tr>
</table>
[/Quote]
这个东西就只适合初学者玩一下,用到实际会被整成肛裂
lei4674890 2009-11-10
  • 打赏
  • 举报
回复
disaply-tag看下这个标签
F_F_B_M 2009-11-10
  • 打赏
  • 举报
回复
<%
request.setCharacterEncoding("utf-8");
response.setHeader("gbk","utf-8");
Connection con;
Statement stm;

ResultSet rs;
try{
Class.forName("com.mysql.jdbc.Driver");
}catch(Exception e)
{
e.printStackTrace();
}
try{

con=DriverManager.getConnection("jdbc:mysql://localhost:3306/lipin_db?useUnicode=true&characterEncoding=utf-8","root","root");
stm=con.createStatement();

String sqlString="select * from lipin1 where type=1";
rs=stm.executeQuery(sqlString);



int pageSize = 2;//定义每页显示的记录数;
int pageCount; //定义分页后总页数变量
int nowPage; //定义当前页变量
int rowCount; //定义数据库中记录总条数变量
int nowRow;//定义当前记录行号变量
rs.last();
rowCount = rs.getRow();//获取数据库中记录总条数
String strPage = request.getParameter("page");//获取地址栏page变量的值

if (rowCount % pageSize == 0) {
pageCount = rowCount / pageSize;
} else {
pageCount = (rowCount / pageSize) + 1;
}//计算分页后总页数

if (strPage == null || strPage == "") {
nowPage = 1;
} //如果地址栏没有page变量或page变量值为空,则默认为第一页
else {
nowPage = Integer.parseInt(strPage);
}

if (nowPage < 1) {
nowPage = 1;
} else if (nowPage > pageCount) {
nowPage = pageCount;
}

nowRow = (nowPage * pageSize - (pageSize - 1));
rs.absolute(nowRow); //将指针定位到指定的记录行行号
%>
<table width="270" border="0">
<tr>
<td width="264"><font size="1">您的位置:首页>鲜花</font></td>
</tr>
</table>
pangpanglovezz 2009-11-10
  • 打赏
  • 举报
回复
看你想怎么发展 分页这个 公司一般都有现成的 会用就行了 想自己做项目 网上有的是 核心思想知道就行了啊
加载更多回复(2)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧