0

我已经使用 struts 迭代器标记显示了一个表。现在每一行最后都有一个编辑链接。当单击编辑按钮时,我需要能够将该行发送到操作中。

但我无法理解如何做到这一点。我有

<s:form action="/execute" id="frm" name="frm" method="POST">
    <table style="width: 800px; ">
        <thead>
            <tr>
                <th>ID</th>
                <th>Name</th>        
                <th>Actions </th>      
            </tr>
        </thead>
        <s:iterator value="listToIterate" var="row" status="stat" begin="0" >
            <tbody>    

                <tr>    
                    <td><s:property value="ID"  /></td>
                    <td><s:property value="Name"  /></td>               
                    <td><s:a href="#" onclick="document.forms['frm'].submit();">
                            edit<s:param name="Name" value="%{#row[2]}"/></s:a></td>        
                    </tr>       
                </tbody>    
        </s:iterator>
    </table>
</s:form> 

使用 param 标记我想将该行设置为参数,以便我可以在我的操作中检索它。我该怎么做呢 ?

4

1 回答 1

1

假设您的表单正确显示 id ......然后将您的 s:a 替换为以下表单:

<s:a namespace="/yournamespace" action="the-edit-action">
   edit<s:param name="ID" value="ID"/>
</s:a>

我宁愿把ID叫做id。the-edit-action 将需要一个 getter 和 setter 来获取 id。

于 2013-02-17T11:29:37.490 回答