有什么办法可以在Spring Webflux中实现分页和Spring数据响应 [英] Is there any way to implement pagination in spring webflux and spring data reactive

查看:559
本文介绍了有什么办法可以在Spring Webflux中实现分页和Spring数据响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图理解spring 5的反应式部分.我创建了一个简单的rest端点,用于使用spring web-flux和spring数据反应式(mongo)查找所有实体,但是看不到如何实现分页. /p>

这是我在Kotlin中的简单示例:

@GetMapping("/posts/")
fun getAllPosts() = postRepository.findAll()

这是否意味着反应性端点不需要分页?是否有某种方法可以使用此堆栈从服务器端实现分页?

解决方案

Spring Data中的反应式支持不提供Page返回类型的方法.仍然在方法签名中支持Pageable参数,该方法签名将limitoffset传递给驱动程序,并因此传递给驱动程序本身,并返回一个Flux<T>并发出请求的范围.

 Flux<Person> findByFirstname(String firstname, Pageable pageable);
 

有关更多信息,请查看当前的

Does it mean that reactive endpoint does not require pagination? Is some way to implement pagination from server side using this stack?

The reactive support in Spring Data does not provide means of a Page return type. Still, the Pageable parameter is supported in method signatures passing on limit and offset to the drivers and therefore the store itself, returning a Flux<T> that emits the range requested.

Flux<Person> findByFirstname(String firstname, Pageable pageable);

For more information please have a look at the current Reference Documentation for 2.0.RC2 and the Spring Data Examples.

这篇关于有什么办法可以在Spring Webflux中实现分页和Spring数据响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆