调用 fnPagingInfo 函数时 oSettings 为空

oSettings is null when calling fnPagingInfo function

我目前正在尝试解决 table 的问题。

我正在使用 JSTL 从我的控制器打印一个对象内部的对象列表,在多个 table 中显示结果。

一切正常,直到我在我的 javascript 中应用数据 table 函数,导致 Cannot read property '_iDisplayStart of null 并且当我检查函数时 $.fn.dataTableExt.oApi.fnPagingInfo 似乎oSettings 为空。

这是我的 javascript 代码:

var oInit ={
            'sDom': "<'datatables-action-box'<'span6 link-tabla'r><'span18 link-tabla'l>>t<'datatables-action-box'<'span2 link-tabla'i><'span2'p>>",
            'bAutoWidth': false,
            'bFilter': false, 
            'bLengthChange': true,
            'iDisplayLength': 10,
            'aLengthMenu': [1, 5, 10, 15, 50, 100],
            'sPaginationType': 'bootstrap',
            'aoColumns': aoColumns,
            'oLanguage': oLanguage,
            'aaSorting': [[2,'desc']] 
    };

    $('table#tabla_paginada_obtener_portales').dataTable(oInit); 

    var buttonCustom = $("#buttonCustom");
    var buttonPlaceholder = $(".dataTables_rango");
    buttonPlaceholder.html(buttonCustom);

这是我的 jsp:

<c:if test="${not empty portals}">
    <c:forEach var="bloque" items="${portals.blocs}">
        <c:choose>
            <c:when test="${not empty bloque.items}">
                <table id="tabla_paginada_obtener_portales" class="table">
                    <thead>
                        <tr>
                            <th>Title</th>
                            <th>Description</th> 
                        </tr>
                    </thead>
                    <c:forEach var="item" items="${bloque.items}">
                        <c:if test="${not empty item }">
                            <tbody>
                                <tr>
                                    <td><c:out value="${item.titol}" /></td>
                                    <td><c:out value="${item.descripcio}" /></td>

                                </tr>
                            </tbody>
                        </c:if>
                    </c:forEach>
                </table>
                <br>
            </c:when>
            <c:otherwise>
                <spring:message code="checklist.obtenerPortal.tabla.noresult" />
                <br>
                <br>
            </c:otherwise>
        </c:choose>
    </c:forEach>
</c:if>

如您所见,我有一个名为 portals 的对象,它有一个名为 blocs 的对象列表,当这个对象不是空我为每个打印 table 等于它具有 项目 的时间创建一个,然后我打印项目列表内容。它是一个对象内的列表。

我不知道是因为视图页面中有多个 table 还是我遗漏了其他内容。我能做什么?

我找到了解决方案,很简单,问题出在 JSP,每个函数的标签都必须在

之外

像这样:

<tbody>
    <c:forEach var="item" items="${bloque.items}">
        <c:if test="${not empty item }">
            <tr>
                <td><c:out value="${item.titol}" /></td>
                <td><c:out value="${item.descripcio}" /></td>
            </tr>
        </c:if>
    </c:forEach>
</tbody>

标签用于将正文内容分组在一个HTMLtable中,在一个里面对于每个数据table无法进行分页,因为它重复constaly和代码搞砸了。