【发布时间】:2020-11-14 03:38:51
【问题描述】:
我正在尝试使用 DataTable Ajax 请求向 Spring Boot 控制器发送带有一些数据的 POST 请求,并将数据设置到 Table 中。
HTML 表格:
<table id="assignmentDetails" class="display" style="width:100%">
<thead>
<tr>
<th>Id</th>
<th>title</th>
<th>doc</th>
<th>end</th>
<th>start</th>
</tr>
</thead>
</table>
JQuery:
$(document).ready(function(){
$('#collapse'+id).on('shown.bs.collapse', function() {
$('#assignmentDetails').DataTable({
"ajax": {
"url": "http://localhost:9091/assignment/getassignments",
"dataSrc": '',
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({"moduleId":"10010","subModuleId":null}),
},
"columns": [
{ data: "Id" },
{ data: "title" },
{ data: "doc" },
{ data: "start" },
{ data: "end" },
]
} );
});
});
在服务器上发送请求后,我收到Status Code 400 错误。
控制台错误:
2020-07-24 14:26:53.963 WARN 2724 --- [nio-9091-exec-7] .wsmsDefaultHandlerExceptionResolver:已解决 [org.springframework.http.converter.HttpMessageNotReadableException:JSON 解析错误:意外字符( '='(代码 61)):分隔根级值的预期空间;嵌套异常是 com.fasterxml.jackson.core.JsonParseException: Unexpected character ('=' (code 61)): 需要空格分隔根级值 在 [来源:(PushbackInputStream);行:1,列:3]]
谁能帮我使用datatable post reqeust向服务器发送POST请求
【问题讨论】:
标签: jquery spring spring-boot datatable datatables