Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将选中的复选框值传递到Struts2中的数据库_Java_Jsp_Struts2_Jstl - Fatal编程技术网

Java 将选中的复选框值传递到Struts2中的数据库

Java 将选中的复选框值传递到Struts2中的数据库,java,jsp,struts2,jstl,Java,Jsp,Struts2,Jstl,我正在使用Struts2,这是我在JSP中的表单 <s:form target="_top" cssClass="table-controls form-wrapper" name="incentives" id="frmIncentives" action="saveIncentives.action" method="post"> <div id="actionErrors" style="color: red;">

我正在使用Struts2,这是我在JSP中的表单

<s:form target="_top" cssClass="table-controls form-wrapper" name="incentives" id="frmIncentives" action="saveIncentives.action" method="post">
        <div id="actionErrors" style="color: red;">
                        <s:actionerror />
                        <s:fielderror />
        </div>
            <table id ="showIncentives" cellspacing="0" cellpadding="0" border="1" width="500" >
                <tr style="font-weight: bold">
                    <td><s:checkbox name="Select All" id="select_all"
                            theme="simple" /></td>
                    <td>
                    <td></td>
                    <td></td>
                    <td><s:text name="Marketing Incentive" /></td>
                    <td></td>
                    <td><s:text name="Advertising Incentive" /></td>
                    <td></td>
                    <td><s:text name="Channel Placement Incentive" /></td>
                    <td></td>
                    </tr>
            <s:iterator value="incentiveList" status="stat">
                    <tr>
                        <td><s:checkbox name="checkboxes[%{#stat.index}]" theme="simple" /></td>
                        <td></td>
                        <td><s:property value="pricingTierId" /> <s:hidden value="%{incentiveList.pricingTierId}" /></td>
                        <td><s:property value="marketingAmount" /> <s:hidden value="%{incentiveList.marketingAmount}" /></td>
                        <td></td>
                        <td><s:property value="marketingIncentive" /></td>
                        <td></td>
                        <td><s:property value="advertizingIncentive" /></td>
                        <td></td>
                        <td><s:property value="channelPlacementIncentive" /></td>
                        <td></td>
                    </tr>
            </s:iterator>
            </table>
            <c:if test="${fn:length(incentiveList) == 0}">
                <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="true"/>
            </c:if>
            <c:if test="${fn:length(incentiveList) gt 0}">
                <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="false"/>
            </c:if>
    </s:form>

  • pricingTierId、营销意识、广告激励、, 渠道安置激励和渠道安置激励
  • 尽管Action类中有getter和setter,但仍以null形式传递给函数

    我已按以下建议进行了更改

    <s:iterator value="incentiveList" status="stat">
                    <tr>
                        <td><s:checkbox name="checkboxes[%{#stat.index}]" theme="simple" /></td>
                        <td></td>
                        <td><s:property value="pricingTierId"  /> <s:hidden name="pricingTierId" value="%{incentiveList.pricingTierId}" /></td>
                        <td><s:property value="marketingAmount" /> <s:hidden name="marketingAmount" value="%{incentiveList.marketingAmount}" /></td>
                        <td></td>
                        <td><s:property value="marketingIncentive" />
                        <s:hidden name="marketingIncentive" value="%{incentiveList.pricingTierId}" />
                        </td>
                        <td></td>
                        <td><s:property value="advertizingIncentive"/> 
                        <s:hidden name="advertizingIncentive" value="%{incentiveList.pricingTierId}"/> 
                        </td>
                        <td><s:property value="channelPlacementIncentive" /> 
                        <s:hidden name="channelPlacementIncentive" value="%{incentiveList.pricingTierId}" />
                        </td>
                        <td></td>
                    </tr>
            </s:iterator>   
    
    
    
    仍然所有的值都被传递为null。
    请建议您的表格如下所示

    <s:form target="_top" cssClass="table-controls form-wrapper" name="incentives" id="frmIncentives" action="saveIncentives.action" method="post">
            <div id="actionErrors" style="color: red;">
                            <s:actionerror />
                            <s:fielderror />
            </div>
                <table id ="showIncentives" cellspacing="0" cellpadding="0" border="1" width="500" >
                    <tr style="font-weight: bold">
                        <td><s:checkbox name="Select All" id="select_all"
                                theme="simple" /></td>
                        <td>
                        <td></td>
                        <td></td>
                        <td><s:text name="Marketing Incentive" /></td>
                        <td></td>
                        <td><s:text name="Advertising Incentive" /></td>
                        <td></td>
                        <td><s:text name="Channel Placement Incentive" /></td>
                        <td></td>
                        </tr>
                <s:iterator value="incentiveList" status="stat">
                        <tr>
                            <td><s:checkbox name="checkboxes[%{#stat.index}]" theme="simple" /></td>
                            <td></td>
                            <td><s:property value="pricingTierId" /> <s:hidden name="pricingTierId" value="%{incentiveList.pricingTierId}" /></td>
                            <td><s:property value="marketingAmount" /> <s:hidden name="marketingAmount" value="%{incentiveList.marketingAmount}" /></td>
                            <td></td>
                            <td><s:property value="marketingIncentive" /><s:hidden name="marketingIncentive" value="%{incentiveList.marketingIncentive}" /></td>
                            <td></td>
                            <td><s:property value="advertizingIncentive" /><s:hidden name="advertizingIncentive" value="%{incentiveList.advertizingIncentive}" /></td>
                            <td></td>
                            <td><s:property value="channelPlacementIncentive" /><s:hidden name="channelPlacementIncentive" value="%{incentiveList.channelPlacementIncentive}" /></td>
                            <td></td>
                        </tr>
                </s:iterator>
                </table>
                <c:if test="${fn:length(incentiveList) == 0}">
                    <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="true"/>
                </c:if>
                <c:if test="${fn:length(incentiveList) gt 0}">
                    <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="false"/>
                </c:if>
        </s:form>
    
    
    
    您没有在任何输入字段中使用name属性。这就是为什么它是空的。只需为输入字段指定name属性。aa也为这些字段添加s:hidden,就像您对其他字段所做的那样。Andrea请给我举个例子谢谢Praveen,但有一个问题,为什么在其他属性的隐藏名称中,value=“%{incentiveList.pricingTierId}”在很少的地方重复
    <s:form target="_top" cssClass="table-controls form-wrapper" name="incentives" id="frmIncentives" action="saveIncentives.action" method="post">
            <div id="actionErrors" style="color: red;">
                            <s:actionerror />
                            <s:fielderror />
            </div>
                <table id ="showIncentives" cellspacing="0" cellpadding="0" border="1" width="500" >
                    <tr style="font-weight: bold">
                        <td><s:checkbox name="Select All" id="select_all"
                                theme="simple" /></td>
                        <td>
                        <td></td>
                        <td></td>
                        <td><s:text name="Marketing Incentive" /></td>
                        <td></td>
                        <td><s:text name="Advertising Incentive" /></td>
                        <td></td>
                        <td><s:text name="Channel Placement Incentive" /></td>
                        <td></td>
                        </tr>
                <s:iterator value="incentiveList" status="stat">
                        <tr>
                            <td><s:checkbox name="checkboxes[%{#stat.index}]" theme="simple" /></td>
                            <td></td>
                            <td><s:property value="pricingTierId" /> <s:hidden name="pricingTierId" value="%{incentiveList.pricingTierId}" /></td>
                            <td><s:property value="marketingAmount" /> <s:hidden name="marketingAmount" value="%{incentiveList.marketingAmount}" /></td>
                            <td></td>
                            <td><s:property value="marketingIncentive" /><s:hidden name="marketingIncentive" value="%{incentiveList.marketingIncentive}" /></td>
                            <td></td>
                            <td><s:property value="advertizingIncentive" /><s:hidden name="advertizingIncentive" value="%{incentiveList.advertizingIncentive}" /></td>
                            <td></td>
                            <td><s:property value="channelPlacementIncentive" /><s:hidden name="channelPlacementIncentive" value="%{incentiveList.channelPlacementIncentive}" /></td>
                            <td></td>
                        </tr>
                </s:iterator>
                </table>
                <c:if test="${fn:length(incentiveList) == 0}">
                    <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="true"/>
                </c:if>
                <c:if test="${fn:length(incentiveList) gt 0}">
                    <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="false"/>
                </c:if>
        </s:form>