Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 断开ArrayList并显示在Struts 1中_Java_Jsp_Controller_Struts_Struts Action - Fatal编程技术网

Java 断开ArrayList并显示在Struts 1中

Java 断开ArrayList并显示在Struts 1中,java,jsp,controller,struts,struts-action,Java,Jsp,Controller,Struts,Struts Action,我遇到了一个显示包含2750行的ArrayList的问题。要显示行的struts代码是: <c:forEach items="${customerlist}" var="beneficiaryListval"varStatus="ForIndex" > <tr id="<c:out value="${beneficiaryListval.customerId}" />"> <td><c:out value="${beneficiaryLi

我遇到了一个显示包含2750行的
ArrayList
的问题。要显示行的struts代码是:

<c:forEach items="${customerlist}" var="beneficiaryListval"varStatus="ForIndex" >
<tr id="<c:out value="${beneficiaryListval.customerId}" />">
  <td><c:out value="${beneficiaryListval.fullName}" /></td>
    <td><c:out value="${beneficiaryListval.mobileNo}" /></td>
<td><c:out value="${beneficiaryListval.passportNo}" /></td>
    <td><c:out value="${beneficiaryListval.beneficiaryCount}" /></td>
</tr>
<%rowID++;%>
</c:forEach>

现在,我需要打破
arraylistcustomerlist
并以50块的形式发送到JSP,并在JSP中显示或显示它们,以便在渲染时不会太慢

我建议使用分页机制,以便在给定时间加载50或100条记录。看看这个

标签有
偏移量
长度
属性,可用于显示集合的部分。下面将显示
ArrayList
中的前50个元素

<logic:iterate name="customerlist" id="customer" indexId="customerNum" offset="0" length="50">
    <tr id="${customer.customerId}">
        <td>${customer.fullName}</td>
        ...
    </tr>
</logic:iterate>

${customer.fullName}
...

不建议在列表中存储2750条记录。请考虑它的含义,当你从DB /存储读取它,当你把它传递到你的Web /应用服务器。此外,您可能不需要一次性使用所有这些工具

请考虑在100个块中一次获取和显示数据。通过传递索引,您始终可以对服务器进行新调用以获取下一组记录


此外,如果您不使用still,您还必须使用Ajax;通过这种方式,您可以在不刷新的情况下继续将剩余数据追加到页面。

您不应该将列表
customerlist
分解为“分块发送到jsp”。相反,您可以中断将返回给定数量记录的方法,即
customerManager.getCustomerForBeneficiaryWithCount(perPage)
或使用JSP逻辑标记来限制使用两个参数来呈现行
firstRow
perPage

在这种情况下,您必须将所有2750条记录加载到内存中吗?@guess\u me是的,您将让db向您发送2750条记录,您将这些记录转换为2750个对象,仅使用其中的50条。但这将只显示50行,我需要显示所有数据,但每次渲染50个。@Survivor-2012这到底是什么意思?您正在尝试实现分页吗?我已经开始使用jqGrid和jqueryUI主题来实现这个目的。
<logic:iterate name="customerlist" id="customer" indexId="customerNum" offset="0" length="50">
    <tr id="${customer.customerId}">
        <td>${customer.fullName}</td>
        ...
    </tr>
</logic:iterate>