我的数据是 List<List<Shift>> defaultShiftTime;现在我要获取所有的 defaultShiftTime.get(i).get(0).hours请问如何实现?
下面这个例子不行<nested:iterate id="shiftTime" name="permanagerForm" property="defaultShiftTime" indexId="index">
<html:text property='hours' name="shiftTime[0]" indexed="true"/>
</nested:iterate>错误提示 javax.servlet.jsp.JspException: Cannot find bean shiftTime[0] in any scope

解决方案 »

  1.   

    你那样子写好像有点问题,name="shiftTime[0]"没有这种用法,你可以两次遍历集合,然后再用<logic:equals/>判断一下,
    判断你要的第一个就行了
      

  2.   

    谢谢,上面的例子举的有点简单,实际上我要的是一个像这样的东西
    <nested:iterate id="shiftTime" name="permanagerForm" property="defaultShiftTime" indexId="index">
    <html:select name="shiftTime[0]" property="pkid" indexed="true">
    <html:options collection="shiftTime" labelProperty="description" property="pkid"/>
    </html:select>
    <html:text property='hours' name="shiftTime[0]" indexed="true"/>
    </nested:iterate>List <List <Shift>> defaultShiftTime; 
    前面下拉表里装有 defaultShiftTime.get(i),默认值为defaultShiftTime.get(i).get(0).pkid
    后面默认值是 defaultShiftTime.get(i).get(0).hours
    以后还要加入ajax,当前面下拉表数值onchange时,修改后面text的值
      

  3.   

    <nested:iterate id="shiftTime" name="permanagerForm" property="defaultShiftTime" indexId="i">
    <nested:iterate id="shift" name="permanagerForm" property='<%= "defaultShiftTime[" + i + "]" %>' indexId="j">
    <logic:equal name="j" value="0">
    <html:select property="pkid" name="shift" indexed="true">
    <html:options collection="shiftTime" labelProperty="description" property="pkid"/>
    </html:select>
    <html:text property='hours' name="shift" indexed="true"/>
    </logic:equal> 
    </nested:iterate>
    </nested:iterate>写了个这样的,还能用,谢谢提示