Ajax数据表服务器端处理绘图

时间:2018-07-17 08:59:16

标签: ajax datatable

在服务器端处理期间,从服务器“ draw”发送的参数之一为空,但是我无法确定在哪种情况下从服务器将参数作为空发送,有人遇到过这种情况吗?之前的问题,我尝试浏览该应用程序,但无法复制此问题,仅收到一次此问题,但无法重现。

基本上,我们的应用程序中有一个数据表,其中的数据通过ajax调用填充,但是在其中一种情况下,“ draw”参数从服务器发送为null。

1 个答案:

答案 0 :(得分:0)

    This is the content of the ftl file(similar to HTML file) which is used server side processing :

"processing": true,
stateSave: true,
"serverSide": true,
"pageLength": 10,
                "lengthMenu": [10, 25, 50, 100],"pagingType": "full_numbers",
                "scrollX": "true","scrollY": 500,
                "ajax": {
                    "url": "/platform/${registry}/facility${facilityId}/case-list/load",
                    "type": 'POST',
                    "data": function (d) {
                        d.visibleColumns = getVisibleColumns();
                    },
                    headers: {
                        'X-CSRF-Token': $('meta[name="_csrf"]').attr('content')
                    }
                },

    There is a code in the same ftl file where the application is manually sending the parameters to the server:
    var url = "/platform/${registry}/facility${facilityId}/case-list/export?output=excel&draw=1&start=0&length=100000";

    Though we are not doing anything with these paramerters in the controller class(Spring MVC contoller)

    This is the code in the java class, which is trying to read this parameter value and parsing it to int , since "req.getParameter("draw")" value is null, its throwing NumberFormatException in the code, but not able to replicate in which scenario.

    public int getDraw() {
        return Integer.parseInt(req.getParameter("draw"));
      }