Java 使用 struts 2 标签的列表总长度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6385875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-16 05:29:56  来源:igfitidea点击:

Total length of list in using struts 2 tag

javastruts2

提问by Vinoth Kumar C M

I iterate a list using Struts 2 tags.

我使用 Struts 2 标签迭代一个列表。

<s:iterator value="popUpScreenDetailsList" status ="rowCounter">
    //do something
<s:/iterator>

Is there a way, by which I can get the length of the list without iterating?

有没有办法,通过它我可以在不迭代的情况下获得列表的长度?

The motivation to do it, is to use javascript to validate checkboxes.

这样做的动机是使用 javascript 来验证复选框。

采纳答案by nmc

If it's a Java List object, then you can also get the length (size) by

如果它是 Java List 对象,那么您还可以通过以下方式获取长度(大小)

<s:property value="%{getPopUpScreenDetailsList().size()}"/>

<s:property value="%{getPopUpScreenDetailsList().size()}"/>

回答by Chathuranga Withana

<s:property value="popUpScreenDetailsList.size"/>

回答by user2025405

If it's a Java List object, then you can also get the length (size) by

如果它是 Java List 对象,那么您还可以通过以下方式获取长度(大小)

not getPopUpScreenDetailsList().size()

不是 getPopUpScreenDetailsList().size()