如何在一个jsp显示3 ArrayList中的? [英] how to display 3 arraylist's in a jsp?
问题描述
我在一个表中显示3数组列表..在的ArrayList是从一个servlet转发。值要来的JSP。好像我们显示仅PRG是沃金,但可显示3数组列表一个阵列列表是一个问题。
c为C:VAR的forEach =auctionDO项=$ {} auctionDOListServlet>
< TR DIV CLASS =奇>
< TD风格=FONT-SIZE:14px的;>< A HREF =/ myproject的/ S / PermanentUserAuctionHistoryInner>< C:从价值=$ {auctionDO.auctionName}/> &所述; / A>&下; / TD>
< TD> c为C:出值=$ {} auctionDO.endDate/> < / TD>
< TD> c为C:出值=$ {} auctionDO.status/>< / TD>
< TD> c为C:出值=$ {} depotDo.depotName/>< / TD>
< TD> c为C:出值=$ {} userAuctionRelDo.bidAmt/>< / TD>
< / TR>
< / C:的forEach>
如auctionDOListServlet中的foreach提供其显示正确..未显示depotDO和userAuctionRelDO ..
如何显示其他2的ArrayList ??
在的ArrayList是从Servlet进行传递如下:
了request.setAttribute(auctionDOListServlet,auctionDOListServlet);
了request.setAttribute(depotDOListServlet,depotDOListServlet);
了request.setAttribute(userAuctionRelDOListServlet,userAuctionRelDOListServlet);
我已经合并三个列表分为1列表
megaList.addAll(auctionDOListServlet);
megaList.addAll(depotDOListServlet);
megaList.addAll(userAuctionRelDOListServlet);
现在如何显示此为每个?将这项工作?
其中,兆是变量??
< TD> c为C:出值=$ {} mega.endDate/> < / TD>
这怎么样了,现在车厂为名称和bidamt错误,因为他们是在一个完全不同的DO ..笏办??
如何显示其他2的ArrayList ??
块引用>当你做了。
depotDOListServlet
和userAuctionRelDOListServlet
两个数组列表,然后同样的方式,可以使用c为C:的forEach&GT ;< / C:的forEach>
来遍历这些名单c为C:VAR的forEach =auctionDO项=$ {} auctionDOListServlet>
< TR DIV CLASS =奇>
< TD风格=FONT-SIZE:14px的;>< A HREF =/ myproject的/ S / PermanentUserAuctionHistoryInner>< C:从价值=$ {auctionDO.auctionName}/> &所述; / A>&下; / TD>
< TD> c为C:出值=$ {} auctionDO.endDate/> < / TD>
< TD> c为C:出值=$ {} auctionDO.status/>< / TD>
c为C:VAR的forEach =depotDo项=$ {} depotDOListServlet>
< TD> c为C:出值=$ {} depotDo.depotName/>< / TD>
< / C:的forEach>
c为C:VAR的forEach =userAuctionRelDo项=$ {} userAuctionRelDOListServlet>
< TD> c为C:出值=$ {} userAuctionRelDo.bidAmt/>< / TD>
< / C:的forEach>
< / TR>
< / C:的forEach>记住对于列表中的每个项目
auctionDOListServlet
休息两个列表,每次将迭代。i have to display 3 array lists in a table.. the arraylists are forwarded from a servlet. the value s coming to the jsp. as if we display one array list alone the prg is woking but to display 3 array lists is a problem.
<c:forEach var="auctionDO" items="${auctionDOListServlet}"> <tr div class="odd"> <td style="font-size:14px;"><a href="/myproject/s/PermanentUserAuctionHistoryInner"><c:out value="${auctionDO.auctionName}"/> </a></td> <td><c:out value="${auctionDO.endDate}"/> </td> <td><c:out value="${auctionDO.status}"/></td> <td><c:out value="${depotDo.depotName}"/></td> <td><c:out value="${userAuctionRelDo.bidAmt}"/></td> </tr> </c:forEach>
as auctionDOListServlet is provided in foreach its displaying correctly.. the depotDO and userAuctionRelDO is not being displayed..
how do i display the other 2 arraylists??
the arraylists are passed from servlet as follows
request.setAttribute("auctionDOListServlet", auctionDOListServlet); request.setAttribute("depotDOListServlet", depotDOListServlet); request.setAttribute("userAuctionRelDOListServlet", userAuctionRelDOListServlet);
i have combined the three list into 1 list
megaList.addAll(auctionDOListServlet); megaList.addAll(depotDOListServlet); megaList.addAll(userAuctionRelDOListServlet);
now how do i display this in for each?? would this work? where mega is the name of the variable??
<td><c:out value="${mega.endDate}"/> </td>
this now hows errors for depot name and bidamt as they are in a totally different DO.. wat to do??
解决方案how do i display the other 2 arraylists??
As you did.
depotDOListServlet
anduserAuctionRelDOListServlet
are two array lists then same way you can use<c:forEach></c:forEach>
to iterate those lists.<c:forEach var="auctionDO" items="${auctionDOListServlet}"> <tr div class="odd"> <td style="font-size:14px;"><a href="/myproject/s/PermanentUserAuctionHistoryInner"><c:out value="${auctionDO.auctionName}"/> </a></td> <td><c:out value="${auctionDO.endDate}"/> </td> <td><c:out value="${auctionDO.status}"/></td> <c:forEach var="depotDo" items="${depotDOListServlet}"> <td><c:out value="${depotDo.depotName}"/></td> </c:forEach> <c:forEach var="userAuctionRelDo" items="${userAuctionRelDOListServlet}"> <td><c:out value="${userAuctionRelDo.bidAmt}"/></td> </c:forEach> </tr> </c:forEach>
Remember that for every item in list
auctionDOListServlet
rest two lists will iterate each time.这篇关于如何在一个jsp显示3 ArrayList中的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!