数据表加载太慢

时间:2019-03-04 08:34:49

标签: spring-boot java-ee datatable datatables

这是我的html代码

<table border=1 id="example" class="display" style="width: 100%">
        <thead>
            <tr>
                <th>title1</th>
                <th>title2</th>
                <th>title3</th>

            </tr>
        </thead>
        <tbody>
            <%                      
            String resultat = "select * from table where 1;//for example
                }
                try {

                    Connection conn = DriverManager.getConnection(url, username, password);
                    PreparedStatement stmt = conn.prepareStatement(resultat);
                    ResultSet rs = stmt.executeQuery();

                    while (rs.next()) {
                        %>


            <tr>
                <td><%=rs.getString("col1")%></td>
                <td style="white-space: pre-line"><%=rs.getString("col2")%></td>
                <td><%=rs.getString("col3")%></td>

            </tr>
            <%
                }
            %>
        </tbody>

但是当我加载具有大行+50000条记录的页面时,加载数据表需要30秒以上的时间,并且我想每页加载一次,例如,如果加载了第一行的10行,则数据表将准备就绪如图所示,其余的将在后端tl中加载,完成所有行。

此处是Datatable的代码:

var table =$('#example').DataTable({
        "columns": [
            { "width": "16%","className": "dt-body-left"},/*css ta3 La premiere colonne*/
            { "width": "65%"},
            {"width": "19%","className": "dt-body-center"},

          ],
          "language": {
              "info":  "<b>Resultat :</b> _TOTAL_ ligne(s) <br/><br/>Affichage de _START_ à _END_ lignes  ",
              "infoEmpty":"<p id='zero'> <b>0</b> Found!! </p>",
            },
        fixedHeader: true,
        searching : true,
        deferRender: true,
        paging : true,
        bProcessing : true,
        dom : 'iBftlrp'
});

0 个答案:

没有答案