-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 –