一尘不染

JSTL在循环中每第5个字段集创建一个新行

jsp

您好,我目前正在迭代并在表中显示字段集的列表。为了设法使布局有些体面。每当循环到达第5个fieldSet时,我都想创建一个新行。谢谢

JSP:

<div class="det" id="displayFields">
    <table class="det">
        <tr>
            <td>
                <c:forEach items="${detFieldMap}" var="detFieldEntry">     
                    <fieldset class="det">         
                        <legend>${detFieldEntry.key}</legend>  
                        <c:forEach items="${detFieldEntry.value}" var="detBean">    
                            <input type="checkbox" name="fieldNames" value="${detBean.fieldName}" <c:if test="${preselectionMap[detBean.fieldName]}">checked="checked"</c:if>>${detBean.displayName}</input>          
                            </br>    
                        </c:forEach> 
                    </fieldset> 
                </c:forEach>
            </td>
        </tr>
    </table>
</div>

阅读 325

收藏
2020-06-10

共1个答案

一尘不染

这工作:

<div class="det" id="displayFields">
    <table class="det">
        <tr>
            <td>
                <c:forEach items="${detFieldMap}" var="detFieldEntry" varStatus="loop">
                    <c:if test="${not loop.first and loop.index % 5 == 0}"> 
                        </td>
                            </tr>
                        <tr>
                            <td>
                    </c:if>
                    <fieldset class="det">         
                        <legend>${detFieldEntry.key}</legend>  
                        <c:forEach items="${detFieldEntry.value}" var="detBean">    
                            <input type="checkbox" name="fieldNames" value="${detBean.fieldName}" <c:if test="${preselectionMap[detBean.fieldName]}">checked="checked"</c:if>>${detBean.displayName}</input>            
                            </br>    
                        </c:forEach> 
                    </fieldset>
                </c:forEach>
            </td>
        </tr>
    </table>
</div>
2020-06-10