问题是,每当我单击Home.xhtml上的下一页链接转到getMoreStatusList页面时,函数getMoreStatusList都会被称为不间断,直到它抛出超出绑定异常的索引为止。我什至在将statusindex方法内的内容打印到控制台时,也将从会话对象getMoreStatusList()和字符串insidegetmorestatusList中获得的索引值打印出来,我使用方法results = results.subList(index,index+5);创建子列表,但此行越来越多不止一次,并且随着每次调用增加index的值,抛出了绑定异常。

1)Home.xhtml

    <h:head>
    </h:head>

    <h:body class="thrColElsHdr">


                <!--  -->
                <div class="items">
                    <div id="scroll_items">
                        <c:forEach var="p" items="#{statusBean.statusList}">
                              //Content

                        </c:forEach>

                    </div>
                </div>

    <a href ="getMoreStatusList.xhtml">Next page</a>
    </h:body>
    </html>


2)状态Bean(其中包含getMoreStatusList函数)

 public class StatusBean {




                public List<Status> getStatusList() {
            FacesContext context = FacesContext.getCurrentInstance();
            HttpSession session = (HttpSession) context.getExternalContext()
                    .getSession(true);
            User user = (User) session.getAttribute("userdet");
            Query query = em.createQuery("SELECT s FROM Status s WHERE s.email='"
                    + user.getEmail() + "' ORDER BY s.timeMillis desc",
                    Status.class);
            List<Status> results = query.getResultList();

            Collections.sort(results);
            results = results.subList(0, 5);

            session.setAttribute("statusindex", 5);
            return results;

        }

        public List<Status> getMoreStatusList() {

            System.out.println("Inside getMoreStatusList");
            FacesContext context = FacesContext.getCurrentInstance();
            HttpSession session = (HttpSession) context.getExternalContext()
                    .getSession(false);
            User user = (User) session.getAttribute("userdet");
            Query query = em.createQuery("SELECT s FROM Status s WHERE s.email='"
                    + user.getEmail() + "' ORDER BY s.timeMillis desc",
                    Status.class);
            List<Status> results = query.getResultList();

            Collections.sort(results);
            int index = (int) session.getAttribute("statusindex");
            System.out.println(index);
            results = results.subList(index,index+5);
            session.setAttribute("statusindex", index + 5);
            return results;

        }


    }


3)getMoreStatusList.xhtml

<h:head></h:head>
<h:body>

            <c:forEach var="p" items="#{statusBean.moreStatusList}">

                      // Content
            </c:forEach>


</h:body>

</html>


3)Stacktrace(由于限制为30000,我已将其缩短了)

Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.527--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.527--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.527--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.529--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.529--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.529--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.529--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.53--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.53--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.53--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.53--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.531--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.531--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
5
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.532--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.532--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.532--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.533--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.533--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.534--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.534--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.535--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.535--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.536--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
10
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.537--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.537--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.537--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.538--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.539--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.539--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.539--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.54--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.54--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.541--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
15
[EL Finest]: 2013-03-03 15:09:47.541--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Comment sql="SELECT COMMENTID, COMMENT, COMMENTBY, EMAIL, PICTURE, STATUSID, TIMEMILLIS FROM COMMENT WHERE (STATUSID = ?)")
[EL Finest]: 2013-03-03 15:09:47.541--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.541--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT COMMENTID, COMMENT, COMMENTBY, EMAIL, PICTURE, STATUSID, TIMEMILLIS FROM COMMENT WHERE (STATUSID = ?)
    bind => [61]
[EL Finest]: 2013-03-03 15:09:47.542--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.543--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.543--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.543--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.544--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.545--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.545--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.545--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.546--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.546--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.546--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.546--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.547--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.547--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.547--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.547--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.548--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
20
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.548--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.548--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.548--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.549--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.549--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.549--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.55--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.55--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.551--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.551--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.551--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.551--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.552--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
25
Inside getMoreStatusList
[EL Finest]: 2013-03-03 15:09:47.553--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.553--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.553--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.554--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.554--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Friend sql="SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)")
[EL Finest]: 2013-03-03 15:09:47.554--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.554--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT FRIENDREQUESTID, EMAIL, FRIENDEMAIL, STATUS FROM FRIEND WHERE (EMAIL = ?)
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.555--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.555--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.555--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.555--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.556--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
[EL Finest]: 2013-03-03 15:09:47.556--UnitOfWork(1909765639)--Thread(Thread[http-bio-8080-exec-1,5,main])--Execute query ReadAllQuery(referenceClass=Status sql="SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC")
[EL Finest]: 2013-03-03 15:09:47.556--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection acquired from connection pool [default].
[EL Fine]: 2013-03-03 15:09:47.556--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--SELECT STATUSID, EMAIL, PICSTATUS, PICSTATUSDESC, PICTURE, STATUSBY, STATUSMSG, TIMEMILLIS, VIDEOSTATUS, VIDEOSTATUSDESC FROM STATUS WHERE (EMAIL = ?) ORDER BY TIMEMILLIS DESC
    bind => [[email protected]]
[EL Finest]: 2013-03-03 15:09:47.557--ServerSession(1973858306)--Connection(1390011245)--Thread(Thread[http-bio-8080-exec-1,5,main])--Connection released to connection pool [default].
30
Mar 03, 2013 3:09:47 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/FreeBird_v.6] threw exception [/getMoreStatusList.xhtml @17,41 test="${p.statusmsg!=null}" /getMoreStatusList.xhtml @17,41 test="${p.statusmsg!=null}": /getMoreStatusList.xhtml @14,60 items="#{statusBean.moreStatusList}": Error reading 'moreStatusList' on type com.bean.StatusBean] with root cause
java.lang.IndexOutOfBoundsException: toIndex = 35
    at java.util.SubList.<init>(AbstractList.java:622)
    at java.util.RandomAccessSubList.<init>(AbstractList.java:775)
    at java.util.AbstractList.subList(AbstractList.java:484)
    at java.util.Vector.subList(Vector.java:1034)
    at com.bean.StatusBean.getMoreStatusList(StatusBean.java:191)
    at sun.reflect.GeneratedMethodAccessor92.invoke(Unknown Source)
    at ......

最佳答案

您应该使用<ui:repeat>(与xmlns:ui="http://java.sun.com/jsf/facelets"一起使用)而不是<c:forEach>

foEach是标记处理程序,repeat是组件。您可以在blog上详细了解两者之间的区别

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head>
</h:head>
<h:body class="thrColElsHdr">
    <ui:repeat var="p" value="#{statusBean.statusList}">
        <div>
            <h:outputText label="Status" value="#{p.value}" />
        </div>
    </ui:repeat>
    <a href="getMoreStatusList.xhtml">Next page</a>
</h:body>
</html>




<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head></h:head>
<h:body>
    <ui:repeat var="p" value="#{statusBean.moreStatusList}">
        <div>
            <h:outputText label="Status" value="#{p.value}" />
        </div>
    </ui:repeat>
    <a href="getMoreStatusList.xhtml">Next page</a>
</h:body>
</html>


要摆脱IndexOutOfBoudsException,请在getMoreStatusList中使用以下内容:

int index = (Integer) session.getAttribute("statusindex");
int end = index+5 > results.size() ? results.size() : index+5;
List<Status> subList = results.subList(index,end);
session.setAttribute("statusindex", end);


并在getStatusList中:

int index = 0;
int end = index+5 > results.size() ? results.size() : index+5;
List<Status> subList = results.subList(0, end);

07-26 07:08