简体   繁体   English

在不使用任何循环的情况下获取JSTL中ArrayList的第二个索引值

[英]Get second index value of ArrayList in JSTL without using any loop

As my subject elaborate about mu question, I have to use 2nd value of ArrayList in JSTL,. 正如我对亩问题的阐述一样,我必须在JSTL中使用ArrayList的第二个值。 Lets say I have some list and I am adding values into it: 可以说我有一些列表,正在向其中添加值:

list.add("XXX");
list.add("YYY");
list.add("ZZZ");

So I have to print ZZZ in my JSP page using JSTL but without using any loop. 因此,我必须使用JSTL在我的JSP页面中打印ZZZ ,但不能使用任何循环。

Please answer. 请回答。

I guess you are asking for accessing a particular index of an ArrayList . 我猜你在要求访问ArrayList的特定索引。 You can do this using array [] operator 您可以使用array []运算符执行此操作

<c:out value="${list[2]}" />

Your question (get second element) and your description (show "ZZZ") don't match. 您的问题(获取第二个元素)和描述(显示“ ZZZ”)不匹配。 Assuming you want to reference the second element in the ArrayList list, you could simply use list.get(2) ; 假设您要引用ArrayList列表中的第二个元素,则只需使用list.get(2)

只需使用$ {list [2]}打印第二个元素。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM