jstl 中多个项目的迭代
我需要在 jstl 中同时迭代 3 个列表。为了迭代我们使用的单个列表,
<c:forEach var = "mfgn" items = "${requestScope.mfgNumber}" varStatus = "status">
do something;
</c:forEach>
我需要做一些事情,比如
<c:forEach var = "mfgn" var = "issue" items = "${requestScope.mfgNumber}" items = "${requestScope.something" varStatus = "status">
mfgNumber;
</c:forEach>
这是否可能,或者是否有其他方法可以同时迭代多个列表。
I have this requirement to iterate over 3 lists at the same time in jstl. for iterating over a single list we use
<c:forEach var = "mfgn" items = "${requestScope.mfgNumber}" varStatus = "status">
do something;
</c:forEach>
I need to do some thing like
<c:forEach var = "mfgn" var = "issue" items = "${requestScope.mfgNumber}" items = "${requestScope.something" varStatus = "status">
mfgNumber;
</c:forEach>
is this possible or there an otherway to iterate over multiple lists at the same time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果它们具有相同的大小,则有两个选项,假设是
List
和List
:将它们合并到单个列表中实体依次代表单个类中彼此列表的项目,例如
List
,其中ManfacturerIssue
是一个 javabean 类,其中包含Integer number< /code> 和
String issues
属性。这样你最终可以这样做:按索引迭代,但这很丑陋且无法维护,因为(填写):
If they have the same size, then there are two options, assuming that it are
List<Integer>
andList<String>
:Merge them in a single list with entities which in turn repesents the items of each other list in a single class like
List<ManfacturerIssue>
where theManfacturerIssue
is a javabean class which containsInteger number
andString issue
properties. This way you can end up doing:Iterate by index instead, this is however ugly and unmaintainable as (fill in):