gpt4 book ai didi

java - 在 spring-boot 应用程序中使用 map 与 DTO

转载 作者:行者123 更新时间:2023-12-01 21:51:27 27 4
gpt4 key购买 nike

<分区>

在 spring-boot 应用程序中接受 POST 请求数据的首选方式是什么:
要么使用 map(key,value) 对映射 post 请求的主体,要么使用 DTO 映射请求内容。
如果有人能够得出每一个的优缺点,那将非常有帮助。

相同的代码片段-
使用 map :

@PostMapping("/updateBalance")
public ResponseEntity<?> updateBalance(RequestEntity<List<Map<String, Object>>> requestData,HttpServletRequest headerRequest)

使用 DTO:

@PostMapping("/updateBalance")
public ResponseEntity<?> updateBalance(List<RequestDTO> requestData,HttpServletRequest headerRequest)

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