gpt4 book ai didi

java - Spring Restful Array 对象作为输入

转载 作者:太空宇宙 更新时间:2023-11-04 12:26:17 25 4
gpt4 key购买 nike

我正在服务器端读取空数据。请帮忙。

我的java脚本代码片段:

$.ajax({
type: "post",
url: "services/save",
data: items,
success: saveSuccess
});

JSON 数据:

[{"id":"SRMS12345","status":"backlog","text":"Make a new Dashboard","content":"New content","tags":"SRMS12345,05-Jul-16","color":"#ffcc66","resourceId":"A70729","className":""},{"id":"SRMS17147","status":"sit","text":"Prepare new release","content":"New content","tags":"SRMS17147,05-Apr-16","color":"#ff7878","resourceId":"A70729","className":""},{"id":"INC2311424","status":"pv","text":"One item added to the cart","content":"New content","tags":"INC2311424,06-Jun-16","color":"#96c443","resourceId":"C02153","className":""},{"id":"INC3215575","status":"uat","text":"Edit Item Price","content":"New content","tags":"INC3215575,02-Oct-16","color":"#96c443","resourceId":"A71787","className":""},{"id":"SRMS15645","status":"backlog","text":"Login 404 issue","content":"New content","tags":"SRMS15645,02-Aug-16","color":"#96c443","resourceId":0,"className":""}]

休息 Controller :

@RestController
public class Services {
@RequestMapping(value="/save", method=RequestMethod.POST)
public boolean saveTaskStatus(ArrayList<AssignmentVO> assignments) {
System.out.println(assignments);
return true;
}
}

输出:

[]

最佳答案

我认为你没有告诉Spring你发送的数据在哪里。

您需要将@RequestBody添加到分配参数中,以便Spring可以知道数据在哪里。

您可以阅读这篇文章。 http://www.leveluplunch.com/java/tutorials/014-post-json-to-spring-rest-webservice/

关于java - Spring Restful Array 对象作为输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38358269/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com