-1

以下のように、アクションクラスにオブジェクトのリストがあります。

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 クラス : (ゲッターとセッターがあります)

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>

ここで立ち往生している私を助けてください。

4

1 に答える 1

0

<s:iterator>jsp here でタグを使用する必要があります。テーブルでの struts2 イテレーターの使用例を見つけることができます。

ポップアップ部分には、任意の Html/JS コンボを使用でき (ブートストラップを使用する場合は を使用できますmodal)、必要に応じてコードを表示または非表示にするだけです

于 2016-03-11T15:13:51.797 に答える