0

在发送发布请求时在我的浏览器的有效负载选项卡中获取以下数据。

"--batch_8c82e185-cbdf-4d70-a62d-a48c9e869bf8 内容类型:应用程序/http;msgtype=request

POST /api/null HTTP/1.1 内容类型:应用程序/json;charset=utf-8 主机:localhost:4200

{"主题":"ankita","开始时间":"2021-11-29T04:00:00.000Z","结束时间":"2021-11-29T04:30:00.000Z","IsAllDay":false," StartTimezone":null,"EndTimezone":null,"RecurrenceRule":null,"Id":4} --batch_8c82e185-cbdf-4d70-a62d-a48c9e869bf8--"

在此处输入图像描述

注意:我正在使用第三方库(syncfusion 日历),我无法使用 JSON 在正文部分自定义我的请求。

我只关心上面的 JSON 数据。

我想在 Spring Boot 的 post API 方法(addAppointment)中访问这些数据。考虑控制器的以下代码:

@RequestMapping(value = "/appointment/{batch}" , method = RequestMethod.POST)
public ResponseEntity<?> addAppointment(@PathVariable Map batch,HttpServletRequest request) throws IOException {

/* code required to access that payload JSON data*/

}

访问该 JSON 数据需要哪一行代码?请帮忙。

4

0 回答 0