html - Struts2 中的复选框对齐问题

标签 html css jsp checkbox struts2

我使用 Struts2 复选框显示带有标题的复选框以及值,如下所示:

<table id="incentiveTable">
    <thead>
        <tr>
            <th colspan="1" style="font-size: 12px; text-align: center; padding: 7px;">     
                Marketing Incentive
            </th>
            <th colspan="1" style="font-size: 12px; text-align: center; padding: 7px;">     
                Advertizing Incentive
            </th>
            <th colspan="1" style="font-size: 12px; text-align: center; padding: 7px;">     
                ChannelPlacement Incentive
            </th>
            </tr>
    </thead>
    <tbody>
        <s:iterator status="stat" value="incentiveList">
            <s:checkbox name="checkboxes[%{#stat.marketingIncentive}]"  theme="simple" />
            <s:checkbox name="checkboxes[%{#stat.advertizingIncentive}]"  theme="simple" />
            <s:checkbox name="checkboxes[%{#stat.channelPlacementIncentive}]"  theme="simple" />
        </s:iterator>
    </tbody>
</table>

但是,复选框没有正确对齐:

enter image description here

我需要标题为 Marketing IncentiveAdvertising IncentiveChannelPlacement Incentive 旁边的复选框

我已经使用了上面的代码但是它不起作用

我进一步修改了代码

<table id="incentiveTable">
                <thead>
                    
                </thead>
                <tbody>
                            <tr>
                                    <td>
                                            Marketing Incentive
                                    </td>
                                    <td>
                                            Advertizing Incentive
                                    </td>
                                    <td>
                                            Advertizing Incentive
                                    </td>
                            </tr>   
                        <s:iterator status="stat" value="incentiveList">
                            <tr>
                                
                                    <td>
                                    <s:checkbox name="checkboxes[%{#incentiveList.marketingIncentive}]"  theme="simple" />
                                    </td>
                                    
                                    
                                <td>
                                    <s:checkbox name="checkboxes[%{#incentiveList.advertizingIncentive}]"  theme="simple" />
                                </td>
                                
                                
                                <td>
                                    <s:checkbox name="checkboxes[%{#incentiveList.channelPlacementIncentive}]"  theme="simple" />
                                </td>
                            </tr>
                        </s:iterator>
                    
                    <s:submit id="submitButton" name="submit" value="Submit Incentives" onclick='return closeWindow()' disabled="true"/>
                    
                </tbody>
            </table>

o/p如第二张图所示 enter image description here

请建议对齐方式

最佳答案

您的标签生成的代码不是有效的 HTML。

自从您使用了 theme="simple" ,不会生成额外的标记,您需要自己处理,通过手动创建 <tr><td>复选框周围的标签:

<tbody>
    <s:iterator status="stat" value="incentiveList">
    <tr>
        <td>
            <s:checkbox name="checkboxes[%{#stat.index}].marketingIncentive"  theme="simple" />
        </td>
        <td>
            <s:checkbox name="checkboxes[%{#stat.index}].advertizingIncentive"  theme="simple" />
        </td>
        <td>
            <s:checkbox name="checkboxes[%{#stat.index}].channelPlacementIncentive"  theme="simple" />
        </td>
    </tr>
    </s:iterator>
</tbody>

编辑:IteratorStatus 的使用也有错误,现已更正。

顺便说一句,为了使它正常工作,您需要确保 checkboxes也是源列表的名称,而不是目标列表,否则您需要使用 value也是属性。

关于html - Struts2 中的复选框对齐问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27483446/

相关文章:

java - JSTL c :set a bean property with an array, 调用了错误的 setter 方法

javascript - AngularJS 代码挂起浏览器

html - 如何将图像和搜索栏对齐在一行中?

html - 为什么我的导航栏会影响图像的居中?

java - JSP页面无法显示3D饼图

javascript - 如何从 JSP 文件打开一个新窗口?

javascript - 针对 Angular ng-show 和 ng-hide 的类

html - 如何在 svg 或 canvas 中绘制箭头曲线……我看到了很多示例,但我不知道如何绘制

javascript - 为什么一个行内 block 元素比其他元素略高

jquery - 搜索输入滑出按钮悬停 CSS3?