-1
我正在使用Swagger在API上工作,我一直在试图弄清楚ResponseEntity是什么,它是如何工作的,以及为什么使用ResponseEntity?这ResponseEntity是什么?
当我运行API,并转到localhost:8080/suspect-api/swagger-ui.html。我可以输入嫌疑人ID和品牌,并调用getSuspect方法。
在英语中,它在背景中做了什么以及ResponseEntity的目的是什么?
请参阅下面的代码:
public ResponseEntity<Suspects> getSuspects(@ApiParam(value = "Brand", required = true) @PathVariable String brand,
@ApiParam(value = "ID", required = true) @PathVariable Long suspectId,
Pageable page, PagedResourcesAssembler assembler) {
return service.getSuspects(brand, suspectId, page, assembler);
}
我已经习惯了返回特定类型(如String),整型,布尔或类似学生甚至是自定义的Java对象的方法。
http://docs.spring.io/spring-framework/docs/current/javadoc- API /组织/ springframework的/ HTTP/ResponseEntity.html –