尝试在Request-Param对象中支持Sort
时出错。例如:
@GetMapping
public ResponseEntity fetch(MyRequestParams params) {
// Here sort is not handled I'm getting the following error:
// "Failed to convert property value of type 'java.lang.String'
// to required type 'org.springframework.data.domain.Sort' for property 'sort'
return ResponseEntity.ok("foo");
}
@Data
public class MyRequestParams {
// some params
private Sort sort;
}
但这可行:
@GetMapping
public ResponseEntity fetch(MyRequestParams params, Sort sort) {
// Here sort is properly handled by SortHandlerMethodArgumentResolver
return ResponseEntity.ok("foo");
}
有人已经面临这个问题吗?怎么解决呢?
注意:我使用的是 Spring-boot-starter-web:2.1.3.RELEASE