【问题标题】:How to pass variable through link in iterator in Struts 2如何通过Struts 2中迭代器中的链接传递变量
【发布时间】:2013-10-17 09:33:39
【问题描述】:

我正在使用 struts2 迭代器标签来列出用户创建的投诉。用户应该能够选择将用户发送到包含有关投诉的更多详细信息的页面的链接。虽然转到下一页有效,但我不知道如何将投诉 ID 带到新页面。

//.jsp Code
<table>
    <tr>
        <td><strong>Complaint #</strong></td>
        <td><strong>Current Status</strong></td>
    </tr>
    <tr>
        <td><a href="<s:url namespace="/staff" action="complaintDetails"/>"><s:property value="cmplntNumber"/></a></td>
        <td>currentStatus</td>


//struts.xml
<action name="complaintDetails" class="complaintInformation" method="complaintDetails">
    <result name="complaintDetails">/complaintDetails.jsp</result>
</action>

现在我可以成功访问到committeeDetails.jsp,我只需要获取用户选择的具体投诉Id即可。

【问题讨论】:

    标签: java struts2 iterator action struts-tags


    【解决方案1】:

    使用&lt;s:param&gt; as 传递投诉ID

    <td><a href="<s:url namespace="/staff" action="complaintDetails">
            <s:param name="compNum" value="%{cmplntNumber}" /></s:url>">
            <s:property value="cmplntNumber"/>
        </a>
    </td>
    

    【讨论】:

    • @MariEmpl 很高兴能帮上忙。
    猜你喜欢
    • 2016-05-26
    • 1970-01-01
    • 1970-01-01
    • 2017-10-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多