【发布时间】:2017-11-16 08:29:46
【问题描述】:
我有一堂课ProductItem
@Data
public class ProductItem {
private String name;
private String description;
private byte[] image;
}
还有Spring rest方法:
@GetMapping(value = "/test")
private ResponseEntity<ProductItem> findProduct() {
ProductItem i= service.getProductItem()
return ResponseEntity.ok(i);
}
我怎样才能在这个类中正确返回byte[]?
【问题讨论】:
-
你想只返回字节还是整个类?
-
有什么问题,它应该可以工作,我认为唯一缺少的是在映射中产生。您的映射应该是 @GetMapping(value = "/test",produces = MediaType.APPLICATION_JSON_VALUE)
标签: arrays json spring spring-restcontroller