如何在OGNL/Struts2中迭代和索引列表列表?

如何在OGNL/Struts2中迭代和索引列表列表?,struts2,ognl,Struts2,Ognl,我有一个配置文件如下的属性: public List<List<String>> getAvailablePassengersJS() <tr> <td>[2236, Middle, Onbenbosin Bawed, true, You can book Tritho Fonand]</td> </tr> 所以我知道“line”解析为ArrayList。似乎暗示我应该能够通过[]符号对数组进行索引。我尝试了更多

我有一个配置文件如下的属性:

public List<List<String>> getAvailablePassengersJS()
<tr>
    <td>[2236, Middle, Onbenbosin Bawed, true, You can book Tritho Fonand]</td>
</tr>
所以我知道“line”解析为ArrayList。似乎暗示我应该能够通过[]符号对数组进行索引。我尝试了更多的{}、#等组合,我不会给你带来负担,但没有效果。 有人能解释为什么这不起作用,以及我需要做什么才能使它起作用吗

更新

尝试下面四元数的建议时,我使用了以下代码:

<s:iterator value="ssn.docked.AvailablePassengersJS" var="line">
<tr id="availPass<s:property value="#line[0]"/>">
    <td><s:property value="#line[1]"/></td>
    <td><s:property value="#line[2]"/></td>
    <td><s:checkbox key="#line[3]" value="false" theme="simple"/>&nbsp;Book</td>
</tr>
</s:iterator>
它主要起作用。不幸的是,该复选框失败:

<tr id="availPass151570">
    <td>Low</td>
    <td>Andadicko Ostan</td>
    <td><input type="checkbox" name="#line[3]" value="true" id="#line_3_"/><input type="hidden" id="__checkbox_#line_3_" name="__checkbox_#line[3]" value="true" />&nbsp;Book</td>
</tr>

低
安达迪科奥斯坦
书
如果我不使用key,id和value的组合也不会起作用。 如果我只知道姓名和身份证:

<td><s:checkbox name="#line[3]" id="#line[3]" value="false" theme="simple"/>&nbsp;Book</td>
如果无法解决此问题:

<td><input type="checkbox" name="Book" value="true" id="#line3"/><input type="hidden" id="__checkbox_#line3" name="__checkbox_Book" value="true" /></td>

如果我只使用名称:

<td><s:checkbox name="#line[3]" value="false" theme="simple"/>&nbsp;Book</td>
它也不起作用:

<td><input type="checkbox" name="#line[3]" value="true" id="#line_3_"/><input type="hidden" id="__checkbox_#line_3_" name="__checkbox_#line[3]" value="true" />&nbsp;Book</td>
如果我只使用id,我会得到一些内部错误:

    <td><s:checkbox id="#line[3]" value="false" theme="simple"/>&nbsp;Book</td>
    <td><input type="checkbox" name="<!-- FREEMARKER ERROR MESSAGE STARTS HERE -->...
Expression parameters.name is undefined on line 23, column 32 in template/simple/checkbox.ftl.
The problematic instruction:
----------
==> ${parameters.name?html} [on line 23, column 30 in template/simple/checkbox.ftl]
私有列表列表;
公共列表getListofList(){
返回列表;
}
公共无效集合列表(列表列表列表){
this.listOfLists=listOfLists;
}
//按索引。


这是一个老问题,但对于其他问题,您需要使用
%{listname[index]}“
作为复选框,例如

<input type="checkbox" name="%{#line_3_[1]}" value="true" id="%{#line_3_[1]}"/>


谢谢您的回复,但我不想重复内部列表。我想索引到其中。您的函数运行并显示所有值。但它没有满足我的要求。我想索引到内部列表中,以便提取特定值。一些用于ID,其他用于显示,其他用于悬停消息。是否要按索引访问内部列表?我不知道要问什么,如果问题用(已尝试)-(已制作)-(但必须)澄清,我将反向否决投票四元数没有提到来回询问信息的长长的线索,他删除了这些信息,使问题停留在上述状态……我的结论是,如果某个声誉排名前4%的人不能简洁地回答某个曾在该领域工作过的人的简单问题25年来,这项技术还没有为黄金时间做好准备。我将坚持使用Struts-1,直到Struts-2能够适应我的需要(而不是必须使我的需要适应Struts-2)。你做了什么来改进这个问题吗?你没有做什么复杂的事情,我相信你想要的任何事情都可以很容易地回答/完成。我已经解释过:struts2复选框的工作原理与迭代的工作原理无关。我花时间回答了最初的问题,然后问题发生了变化。这就像我问java是如何工作的一样对于每个循环工作,然后因为它没有解释我的嵌套printf函数而生气。其他struts2答案会读到这篇文章并认为,这毫无意义。而且问题是免费的,如果你问错了问题,只需问另一个。
<td><input type="checkbox" name="Book" value="true" id="#line3"/><input type="hidden" id="__checkbox_#line3" name="__checkbox_Book" value="true" /></td>
<td><s:checkbox name="#line[3]" value="false" theme="simple"/>&nbsp;Book</td>
<td><input type="checkbox" name="#line[3]" value="true" id="#line_3_"/><input type="hidden" id="__checkbox_#line_3_" name="__checkbox_#line[3]" value="true" />&nbsp;Book</td>
    <td><s:checkbox id="#line[3]" value="false" theme="simple"/>&nbsp;Book</td>
    <td><input type="checkbox" name="<!-- FREEMARKER ERROR MESSAGE STARTS HERE -->...
Expression parameters.name is undefined on line 23, column 32 in template/simple/checkbox.ftl.
The problematic instruction:
----------
==> ${parameters.name?html} [on line 23, column 30 in template/simple/checkbox.ftl]
private List<List<String>> listOfLists;

public List<List<String>> getListOfLists() {
    return listOfLists;
}

public void setListOfLists(List<List<String>> listOfLists) {
    this.listOfLists = listOfLists;
}




    <s:iterator var="list" value="%{listOfLists}">
        <s:iterator var="list" value="#list" status="stat">
              <s:property value="#list[#stat.index]"/> //by index.
        </s:iterator><br/>
    </s:iterator>
<input type="checkbox" name="%{#line_3_[1]}" value="true" id="%{#line_3_[1]}"/>