【发布时间】:2017-07-14 11:15:10
【问题描述】:
我有一个@RepositoryRestController
@RequestMapping(value = "/products/salesReport", method = RequestMethod.GET, produces = "application/json")
public @ResponseBody
ResponseEntity<?> get(
@RequestParam(value = "customer", required = false) Resource<Organization> customer,
@RequestParam(value = "supplier", required = false) Organization supplier,
@DateTimeFormat(pattern = "dd-MM-yyyyy") @RequestParam(value = "startDate", required = false) Date startDate,
@DateTimeFormat(pattern = "dd-MM-yyyyy") @RequestParam(value = "endDate", required = false) Date endDate,
Pageable pageable
) { ...
这里的组织类型请求参数,我想作为 SDR 样式的 uris 传入。当我传入 Long id 时,它可以正常工作并自动转换为实体对象。但是当我传入uri时,我得到:
Failed to convert value of type [java.lang.String] to required type [org.springframework.hateoas.Resource]; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [org.springframework.hateoas.Resource]: no matching editors or conversion strategy found"
有谁知道 Spring 是否真的支持自动将 uri 转换为 @RepositoryRestController 中的实体对象以及如何实现?
【问题讨论】: