Spring MVC + jQuery datatables + тимелист + AJAX - PullRequest
0 голосов
/ 24 мая 2018

Кто-нибудь может указать, где я здесь ошибся?Я продолжаю получать предупреждение `DataTables: table id = usersTable - Ajax error.

Ajax-запрос:

<script th:inline="javascript">

$(document).ready(function () {
    $('#usersTable').DataTable({
        "searching": true,
        "serverSide": true,
        "sAjaxSource": "/list",
        "columns": [
            {"data": "username"},
            {"data": "firstName"},
            {"data": "lastName"},
            {"data": "status"},
            {"data": "role"}
        ]
    })
});

Контроллер:

    @RequestMapping(value = "/list", method = RequestMethod.GET, produces = "application/json")
@ResponseBody
public List<User> listOfUsers() {
    List<User> usersList;
    usersList = userService.getAllUsers();
    return usersList;
}

UI:

       <div class="table-responsive">
                    <table id="usersTable" class="table table-bordered table-hover dataTable">
                        <thead>
                        <tr>
                            <th th:text="#{user.table.heading.username}">User Name</th>
                            <th th:text="#{systemUser.table.heading.firstname}">First Name</th>
                            <th th:text="#{systemUser.table.heading.lastname}">Last Name</th>
                            <th th:text="#{systemUser.table.heading.status}">Status</th>
                            <th th:text="#{systemUser.table.heading.role}">Role</th>
                        </tr>
                        </thead>

                    </table>
                </div>
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...