Springboot |成功响应时,请在请求时使无效响应主体
像这样的Springboot项目中返回响应:
@GetMapping("/users")
public ResponseEntity<List<UserDto>> getUsers() {
return ResponseEntity.ok(adminService.getUsers());
}
AdminService方法:
@Override
public List<UserDto> getUsers() {
return userRepo.findAll()
.stream()
.map(this::convertEntityToDto)
.collect(Collectors.toList());
}
我正在获取用户,但是在这样的成功主体之后,Null
[
{
"id": 7,
"title": "title",
"description": "describtion",
"email": "[email protected]",
"creationDate": "2022-04-21T12:17:40.000+00:00",
"plannedFinishDate": "2022-04-21T12:17:40.000+00:00"
},
{
"id": 8,
"title": "title2",
"description": "describtion2",
"email": "[email protected]",
"creationDate": "2022-04-21T12:17:40.000+00:00",
"plannedFinishDate": "2022-04-21T12:17:40.000+00:00"
}
]null
没有邮递员(在Alamofire的iOS Project中)尝试了此操作,但仍在这里。
Returning a response in SpringBoot project like this:
@GetMapping("/users")
public ResponseEntity<List<UserDto>> getUsers() {
return ResponseEntity.ok(adminService.getUsers());
}
AdminService method:
@Override
public List<UserDto> getUsers() {
return userRepo.findAll()
.stream()
.map(this::convertEntityToDto)
.collect(Collectors.toList());
}
I'm getting users but with null after the success body like this:
[
{
"id": 7,
"title": "title",
"description": "describtion",
"email": "[email protected]",
"creationDate": "2022-04-21T12:17:40.000+00:00",
"plannedFinishDate": "2022-04-21T12:17:40.000+00:00"
},
{
"id": 8,
"title": "title2",
"description": "describtion2",
"email": "[email protected]",
"creationDate": "2022-04-21T12:17:40.000+00:00",
"plannedFinishDate": "2022-04-21T12:17:40.000+00:00"
}
]null
I tried this without postman (in iOS project with alamofire) but still null is here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论