如何从请求Spring Boot转换dataTable

时间:2017-12-09 07:04:04

标签: java spring-boot datatables

我正在学习编程,并希望使用DataTables,我遇到了问题。我不知道如何转换记录...

我在春季启动时有代码

@RequestMapping(path="/seriess", method=RequestMethod.GET)
public Page<SeriesDao> showSeries(@RequestParam(defaultValue="0") int page)
{
    Page<SeriesDao> sss = seriesRepository.findAll(new PageRequest(page, 20));

    return sss;
}
@RequestMapping("/showSeries")
public ModelAndView model(){
    ModelAndView model = new ModelAndView("showSeries");
    return model;
}

接下来我有json,当我去localhost:8080 / seriess,我没有复制所有结果(20)

  

{“content”:[{“id”:41,“name”:“所有员工的平均每周收入:Corpus Christi,TX(MSA)的私人总数”,“档案”:“SMU48185800500000011.csv”, “cassid”: “1d2e556b-031E-4c6f-aec4-981c4e907324”, “类别ID”:3 “datefrom”: “2006-12-31”, “dateto”: “2016年9月30日”, “频率”: 5,“markers”:null,“unit”:“$ per per week”,“feed”:“Macroeconomic_And_Major_Markets”,“createdate”:1476567529000,“changedate”:1483919401000} ........和接下来的19条记录]   “最后”:假, “总页数”:25, “totalElements”:488, “大小”:20, “数量”:0, “排序”:空, “第一”:真 “numberOfElements”:20}

这是我的java脚本代码。我必须正确地从url转换这些数据,但我不知道如何......

$(document).ready( function () {
$('#dataTable').DataTable({
    "processing": true,
    "serverSide": true,
    "ajax": {
        "url": "seriess",
        "dataSrc" : ""
         }
    },
        "columns": [
            { "data": "id"},
            { "data": "name" },
            { "data": "file" },
            { "data": "cassid" },
            { "data": "categoryid" },
            { "data": "datefrom" },
            { "data": "dateto" },
            { "data": "frequency" },
            { "data": "markers" },
            { "data": "unit" },
            { "data": "feed" },
            { "data": "createdate" },
            { "data": "changedate" }
        ]
 })});

1 个答案:

答案 0 :(得分:0)

更改

"ajax": {
        "url": "seriess",
        "dataSrc" : ""
         }
    }

"ajax": {
        "url": "/seriess",
        "dataSrc" : "content"
         }
    }