【问题标题】:How to set check box checked by comparing the database value in struts1.3?如何通过比较struts1.3中的数据库值来设置复选框?
【发布时间】:2011-11-09 08:13:52
【问题描述】:

在我的 Struts1.3 应用程序中,我有一个 Jsp 页面,我在点击该超链接时有一个超链接,我在支票簿中显示来自数据库的所有记录 mycode 是为了显示所有值如下

<table width="932" border="1" align="left" cellpadding="0" cellspacing="0" bordercolor="#E9E9E9">
    <%for (int i = 0; i < landlordList.size(); i++) {%>
    <tr>
        <td width="50" align="left">
            <table width="30" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="20"><label>
                        <html:checkbox value="<%=landlordList.get(i).getLandlordId()%>" property="landlordId"
                                       name="ExporterForm" styleId="landlordId"/>
                    </label>
                    </td>
                </tr>
            </table>
        </td>
        <td class="landlord_name"><%=landlordList.get(i).getLandlordname()%></td>
    </tr>
    <%}%>
</table>

并且property="landlordId" 在我的操作类中被定义为String[]。我还有一个list2,其中包含我查询的几条记录。如果landlordList 包含list2 的任何记录,我如何将list2 与landlordList 进行比较,然后将与这些记录对应的标记为checked。请帮帮我。

【问题讨论】:

    标签: jsp struts


    【解决方案1】:

    我通过multibox得到了解决方案

    <logic:iterate name="<%=Constant.LANDLORDLIST%>" id="customer">
    <tr>
    <td width="50" align="left"><table width="30" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
    <td width="20">
    <label>
    <html:multibox property="landlordid" name="ExporterForm">
    <bean:write name="customer" property="value" />
    </html:multibox>
    </label>
    /td>
    </tr>
    </table></td>
    <td class="landlord_name"><bean:write name="customer" property="label" /></td>
    </tr>
    </logic:iterate>
    

    【讨论】:

    • 通过使用多框和逻辑迭代,我能够解决这个问题。
    猜你喜欢
    • 2011-09-26
    • 2021-11-20
    • 2017-06-21
    • 2020-08-22
    • 1970-01-01
    • 1970-01-01
    • 2014-04-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多