有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在Struts 2中通过表单提交获得迭代器列表

这是我的Java类。processOrderMap是一个带有HashMap类型的ArrayList。此列表在jsp中使用迭代器进行迭代。我想在提交表单时在java类中获得迭代列表。我曾经

"processOrderMap[%{#ctr.index}].processPositionGrid" 

上面的代码用作选择框名称,但它不起作用

public String addProcessOrderGridDetails() {
    try {
        HashMap hmap = new HashMap();//desc,suppartno,qnty,total
        hmap.put("routeIdGrid", routeId);
        hmap.put("routeNoGrid", routeNo);
        hmap.put("routeDescGrid", routeDesc);
        hmap.put("routeListGrid", routeGridList);
        hmap.put("processPositionGrid", processPositionList);

        processOrderMap.add(hmap);


    } catch (Exception e) {
        System.out.println("Exception in addProcessOrderGridDetails Method of productionRouteAction" + e);
    }
    return SUCCESS;
}

这是我的jsp页面

<s:iterator value="processOrderMap" status="ctr">
    <tr>
        <td style="" class="">

            <s:property value="#ctr.count"/>
        </td>
        <td style="" class="">&nbsp;<s:hidden theme="simple" 
                                              id="%{'routeNoGrid' + #ctr.index}" 
                                              name="processOrderMap[%{#ctr.index}].routeNoGrid" 
                                              value="%{routeNoGrid}"/>

            <s:hidden theme="simple" id="%{'routeIdGrid' + #ctr.index}" 
                      name="processOrderMap[%{#ctr.index}].routeIdGrid" 
                      value="%{routeIdGrid}"/>
            <s:property value="routeNoGrid"/>
        </td>

        <td style="">
            <s:select theme="simple" data-rel="chosen" 
                      id="%{'processPositionGrid' + #ctr.index}"
                      name="processOrderMap[%{#ctr.index}].processPositionGrid" 
                      list="processPositionGrid"
                      listKey="id" listValue="name"
                      headerKey="0" headerValue="--SELECT--"
                      cssClass="required input-medium selectMap" />
        </td>

        <td>
            <s:select theme="simple" data-rel="chosen" id="%{'routeListGrid' + #ctr.index}"
                      name="processOrderMap[%{#ctr.index}].routeListGrid" list="routeListGrid"
                      listKey="id" listValue="name" multiple="true"
                      headerKey="0" headerValue="--SELECT--"
                      cssClass="required" />

        </td>
    </tr>
</s:iterator> 

共 (1) 个答案

  1. # 1 楼答案

    #ctr.index用于索引列表。应该通过键访问地图

    "processOrderMap['processPositionGrid']"