【问题标题】:How to set Struts2 dropdown list value, using an iterator variable如何使用迭代器变量设置 Struts2 下拉列表值
【发布时间】:2015-11-06 22:23:54
【问题描述】:

我正在尝试在 struts 迭代器中设置一个选择的下拉菜单,但它无法评估索引变量,导致下拉菜单未被选中。

<s:select list = "itemTypeList" 
       listKey = "itemId" 
     listValue = "description" 
     headerKey = "-1" 
   headerValue = "" 
         value = "%{IteratorList[%{#status.index}].itemBase.{itemId}}" 
/>

我发现对值中的索引进行硬编码可以使其计算正确。
value ="%{IteratorList[0].itemBase.{itemId}}" /&gt;

如何获取要评估的索引?任何帮助表示赞赏!

设置的背景信息 - 用户首先能够过滤 jsp 中的项目列表,然后添加一个使用先前过滤选项的新列表项,以设置与列表项关联的单个下拉列表。

【问题讨论】:

    标签: html jsp select struts2 ognl


    【解决方案1】:

    你不能嵌套%{},你也不需要。以下内容应该足够了:

    <s:select list = "itemTypeList" 
           listKey = "itemId" 
         listValue = "description" 
         headerKey = "-1" 
       headerValue = "" 
             value = "%{IteratorList[#status.index].itemBase.{itemId}}" 
    />
    

    【讨论】:

    • 谢谢,我进行了更改并确认它有效。
    猜你喜欢
    • 2014-08-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多