前端post请求json格式。
topic:{
"id": "",
"userRole": {},
"content": "",
"topicImage": [
"91e0c1b1-548e-4c8f-9323-ddb0141d1d03/topicImage/2133465974.jpg",
"91e0c1b1-548e-4c8f-9323-ddb0141d1d03/topicImage/5167476688.jpg",
"91e0c1b1-548e-4c8f-9323-ddb0141d1d03/topicImage/8636383139.jpg"
],
"address": "",
"creteTime": "",
"remindUser": ""
}
后端代码
// 此处省略getter/setter方法
public class Topic {
private String id;
private User userRole;
private String content;
// List <这里可以填限制值>
// 我这里是限定为字符串数组
private List<String> topicImage;
private String address;
private Date creteTime;
private String remindUser;
private int read_count;
private int like_count;
private int collect_count;
}
@PostMapping("/sendTopic")
@Override
public RequestMessage sendTopic(@RequestBody Topic topic) {
System.out.println(topic);
return topicService.sendTopic(topic);
}
输入: