有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

Java Spring Telegraf数据表不工作

我想用蒲公英数据表和百里香。我的html文件如下:

<table id="myTableId"
     dt:table="true"
    dt:url="@{/dataTable}"
    dt:serverside="true"
    dt:processing="true"
    dt:deferLoading="10">
    <thead>
        <tr>
            <th dt:property="id">Id</th>
            <th dt:property="name" dt:default="My default value !">name</th>
            <th dt:property="state">state</th>
        </tr>
    </thead>
</table>

控制器:

@RequestMapping(value="/dataTable")
public @ResponseBody DatatablesResponse<ApplicationItem>  allAppForTable(@DatatablesParams DatatablesCriterias criterias){

    List<Application>  appList=service.listApplications();
    List<ApplicationItem>  aa=new ArrayList<>();

    for(Application a:appList){

        ApplicationItem ai= new ApplicationItem();
        ai.setId(a.getId());
        ai.setName(a.getName());
        ai.setState(a.getState());
        aa.add(ai);
    }
    Long count=(long)appList.size();
    DataSet<ApplicationItem> dataSet=new DataSet<ApplicationItem>(aa, count,null);


    return DatatablesResponse.build(dataSet, criterias);
}

但当我进入这个页面时,表是空的。第一次加载表时,如何初始化表


共 (1) 个答案

  1. # 1 楼答案

    根据documentationdt:deferLoadgin属性:

    ... allows you to instruct DataTables to not make that initial request, rather it will use the data already on the page (no sorting etc will be applied to it).

    尝试从table的定义中删除dt:deferLoading="10"属性