那位用struts+hibernate3.0做过分页程序呀?请进来提点一下

解决方案 »

  1.   

    query.setFirstIndex(20);
    query.setMaxResults(10);
      

  2.   

    to;dreamover(梦醒了〖http://hellfire.cn〗) 你用qq,msn吗,我可以请教你吗?多谢
      

  3.   

    我这有个S+H分页的例子,加我的QQ:152045347,我给你传。
      

  4.   

    Datastore mainDS = null;
        /* 合计Datastore */
        Datastore sumDS = null;
        /* 分页pages */
        Pages page = null;
        /* 获取表格的主体Datastore并传递回JSP */
        String sql = getSql(request);
        log4j.info("表格的主体SQL:::" + sql);
        //判断是否是Excel输出,如果是就不分页
        if (isToExcel(request))
        {
          mainDS = dc.retrieve(sql);
        }
        else
        {
          page = new Pages(request, dc, sql);
          mainDS = page.getPageData();
        }
        request.setAttribute("mainDS", mainDS);
        /* 获取合计行的Datastore并传递回JSP */
        sql = getSumSql(request);
        log4j.info("合计行SQL:::" + sql);
        sumDS = dc.retrieve(sql);
        request.setAttribute("sumDS", sumDS);
        PageNavigate pageNavigate = new PageNavigate(request, page);
        request.setAttribute("pageNavigate", pageNavigate);
      

  5.   

    to:weky(weky) 可否把合部代码贴出来看下,可否留下qq,msn,多谢
      

  6.   

    外企大连公司寻JAVA开发人才(ERP相关)
    MSN/Email:[email protected] A: Java developer 
    Location     China  -- DaLian 
    Job Family     Product Development 
    Job Term     Full Time 
    Paid Relocation     Negotiable 
    Required Travel     No  
    Summary    
    Required skills: 
    J2EE programming experience (2+ years)  
    Enterprise application development experience (2+ years)  
    Knowledge of IOC frameworks - experience using Spring is considered an added benefit 
    Clear understanding of relational database concepts and SQL to query a database - experience using Postgres is considered an added benefit 
    Knowledge of ORM frameworks - experience using Hibernate is considered an added benefit 
    Good understanding and ability to apply various design patterns in a practical manner 
    Good knowledge of how web application work in general 
    Knowledge of enterprise reporting tools such as Crystal Reports 
    Knowledge of XML, XSLT, and Web Services  
    Development experience in a team environment 
    Good English - spoken and written communication skills Position B: Web application developer  
    Location     China  -- DaLian 
    Job Family     Product Development 
    Job Term     Full Time 
    Paid Relocation     Negotiable 
    Required Travel     No 
    Summary    
    Enterprise application development (2+ years) 
    Java programming experience (2+years) 
    Very good knowledge of Jsp, Html and Javascript 
    Very good knowledge of CSS - candidate should understand and be able to apply modern CSS layout techniques into page design 
    Knowledge of other server side technology/framework (Struts, Tapestry, php, asp.net, Ruby on Rail, etc.) is considered an added benefit 
    UI design experience or interest in UI design  
    Knowledge of enterprise reporting tools such as Crystal Reports 
    Knowledge of XML, XSLT, and Web Services XML,XSLT 
    Preferable to a have a portfolio of past works  
    Development experience in a team environment 
    Good English - spoken and written communication skills. 
    MSN/Email:[email protected]
      

  7.   

    利用HIBERNATE本身具有的分页功能,很容易搞定
      

  8.   

    to:dreamover(梦醒了〖http://hellfire.cn〗) query.setFirstIndex(20);
    query.setMaxResults(10);这个功能仿佛有点问题。
    比如在第一页,可以这样:
    query.setFirstIndex(1);
    query.setMaxResults(10);
    hibernate显示的sql是用select top 10 来的。在第二页就这样:
    query.setFirstIndex(10);
    query.setMaxResults(20);
    hibernate显示的sql是用select top 20 来的。依次类推,最后一页的时候还是要把数据全部检索出来的。不知道各位有甚么好办法,可以提高性能呢?
      

  9.   

    query.setFirstIndex(20);
    query.setMaxResults(10);这样写,hibernate里会帮你构造符合数据库特色的语句的
    在oracle里就是rownum,在mysql里就是limit,在sql里面就是top了