簡體   English   中英

如何使用struts2在彈出窗口中顯示列表數據

[英]How to display list data on pop up using struts2

我的動作類中有對象列表,如下所示。

private ArrayList<Employee> emp_list;
public ArrayList<Employee> getEmp_list() {
    return emp_list;
}
public void setEmp_list(ArrayList<Employee> emp_list) {
    this.emp_list = emp_list;
}

Bean 類:(它有 getter 和 setter)

private String name;
private String designation;
private String project;

現在在jsp頁面上,我希望將此列表數據顯示為按鈕或href單擊(顯示列表大小)的同一頁面上的彈出窗口中的表格

<body>

    <div class="container">
        <h2>Modal Example</h2>
        <!-- Trigger the modal with a button -->
        <table>
            <s:iterator value="emp_list">
                <tr>
                    <td><s:property value="name" /></td>
                    <td>
                        <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Display Details</button>
                    </td>
                </tr>
            </s:iterator>
        </table>

        <!-- Modal -->
        <div class="modal fade" id="myModal" role="dialog">
            <div class="modal-dialog">

                <!-- Modal content-->
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Employee Details</h4>
                    </div>
                    <div class="modal-body">
                        <table>
                            <tr>
                                <td>Name</td>
                                <td><s:property value="name" />
                                </td>
                            </tr>
                            <tr>
                                <td>Designation</td>
                                <td><s:property value="designation" />
                                </td>
                            </tr>
                            <tr>
                                <td>Project</td>
                                <td><s:property value="project" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>

            </div>
        </div>

    </div>

</body>

請幫幫我,我一直卡在這里。

您需要在您的 jsp 中使用<s:iterator>標簽,您可以在這里找到一個帶有表格的 struts2 迭代器使用示例。

對於彈出部分,您可以使用任何 Html/JS 組合(如果使用引導程序,您可以使用modal )並根據需要顯示或隱藏您的代碼

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM