我最多只有94分了,哪位大哥给解决一下,全给一个人!

解决方案 »

  1.   

    hibernate不是有分页的函数?
    Query q = session.createQuery("from Person as p");  
    q.setFirstResult(20000);   
    q.setMaxResults(100);  
    List l = q.list();其中 setFirstResult()函数设置的是从第几笔记录开始取,
         q.setMaxResults(100)函数设置的是取多少笔记录。

         
      

  2.   

    用hibnate做分页的话只相对于小型项目,如果做大型项目建议还是用jsp做
    google搜一下 很多的!
      

  3.   

    2楼给出了最核心的代码。楼主还是google一下吧
      

  4.   

    DAO里面的某一个方法:
    public List findMessageByTechId(final Integer id,final Page page,final Integer rid){
    return (List) this.getHibernateTemplate().execute(
    new HibernateCallback() {
    public Object doInHibernate(Session session)
    throws HibernateException, SQLException {
    Query query = session.createQuery(
    "from Message where techId=:id and recopyId=:rid").setInteger(
    "id", id).setInteger("rid", rid);
    if(page!=null){
    query.setFirstResult(page.getStartnum());
    query.setMaxResults(page.getPagesize());
    }

    if (query.list().iterator().hasNext())
    return  query.list();
    else
    return null;
    }
    });


    }
      

  5.   


    用pager-taglib 做分页显示挺不多
      

  6.   


    action里面控制,接收service并跳转// 从页面获得偏移量
    Integer pagesize=30;

    session.setAttribute("pagesize", pagesize);

    // 从页面获得偏移量
    String offset = request.getParameter("pager.offset"); if (offset == null) {
    // 第一次查询,需要查出记录总数
    String count = "";
    count = this.technologyStoreService
    .findTechByisAuditSharePageNum(2,searchScope.getGrade(),searchScope.getDeptid()).toString();
    // 只需要下传页面总记录数,每页记录数即可。
    session.setAttribute("resultSize", count);
    } if (offset == null || offset.equals("")) {
    offset = "0";
    }
    int intoffset = 0;
    if (offset != null && !offset.equals("")) {
    intoffset = Integer.parseInt(offset);
    } final Page page = new Page(intoffset, pagesize);
    session.setAttribute("pagesize", pagesize);
    // 查询处索要的list
    List tmp = this.technologyStoreService
    .findTechByisAuditSharePage(2, page,searchScope.getGrade(),searchScope.getDeptid());
    session.setAttribute("slist", tmp);
    if (tmp != null && tmp.size() > 0) {
    LinkedList<TechnologyStore> sortList = new LinkedList<TechnologyStore>(tmp);
    session.setAttribute("morelist", sortList);
    }
    String method = "showmodel1";
    session.setAttribute("method", method);

    ActionForward forward = new ActionForward("/technologyStore/indexCom.jsp");

    return forward;
      

  7.   

    jsp页面里用到标签
    <pg:pager items="${sessionScope.resultSizeDetail }"
    maxPageItems="${requestScope.pagesizeDetail}"
    maxIndexPages="<%=10%>" isOffset="<%=true%>"
    url="/lhkjywgl/technologyStore/addTechnologyStore.do"
    export="offset,currentPageNumber=pageNumber"
    scope="request">
    <pg:param name="operate" value="detail"></pg:param>
    <pg:param name="technologyStore1"
    value="${technologyStore1}"></pg:param>
    <pg:param name="recopyId" value="${recopyId}"></pg:param>
    <pg:param name="recopyIdd" value="${recopyIdd}"></pg:param>
    <pg:param name="id" value="${id}"></pg:param>
    <pg:param name="op" value="op"></pg:param>
    <pg:param name="niming" value="0"></pg:param>
    <jsp:include page="/plugins/paging/jsp/altavista.jsp"
    flush="true" />
    <!-- 从page对象中取得属性值firstItem , lastIterm -->
    <pg:page export="firstItem, lastItem">
    <font color="red">本页 <strong><%=firstItem%>
    </strong> -- <strong> <%=lastItem%> </strong>条 <strong>/</strong>
    总记录数 <strong><bean:write name="resultSizeDetail" />
    </strong>条 </font>
    </pg:page>
    </pg:pager>