我想将此代码与 specification-arg-resolver 一起使用使用 @PageableDefault(sort = "createdAt", Direction = Sort.Direction.DESC)
来实现搜索并设置排序顺序,但它不起作用。我试过这个:
@GetMapping("find")
public Page<PaymentTransactionsDTO> getAllBySpecification(
@PageableDefault(sort = "createdAt", direction = Sort.Direction.DESC)
@And({
@Spec(path = "unique_id", spec = LikeIgnoreCase.class)
}) Specification<PaymentTransactions> specification,
Pageable pageable
) {
return transactionService.getAllBySpecification(specification, pageable));
}
你知道我如何在上面的代码中设置带注释的排序顺序吗>
最佳答案
我不了解该库,但我强烈希望 @DefaultPageable
注释需要出现在 Pageable
参数上。
关于java - 在 Pageable 请求中设置默认排序顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56211895/