![](/img/trans.png)
[英]WebFlux - how to check if Mono<ResponseEntity<Flux<MyItem>>> is empty to return 404
[英]Mono<ServerResponse> vs Mono<ResponseEntity<MyPojo>> as return type in Java Spring Webflux @RequestMapping
关于使用Mono<ServerResponse>
与Mono<ResponseEntity<MyPojo>>
作为返回类型的小问题。
我看到一些示例,有时Mono<ServerResponse>
用作 Spring Webflux 的功能路由中的返回类型。
但也看到有时Mono<ResponseEntity<MyPojo>>
在 Spring 功能路由中用作返回类型的示例。
此外,有许多示例在 @Controller、@RequestMapping(Get、Post 映射等)中使用Mono<ResponseEntity<MyPojo>>
作为返回类型。
但是也有一些返回Mono<ServerResponse>
的例子。
请问,退换货有什么区别?
The short of it, as I understand it, is that org.springframework.http.ResponseEntity
is from the original Spring Mvc Framework package and org.springframework.web.reactive.function.server.ServerResponse
is from the spring Reactive package.
反应式 package 具有“兼容性”模式,可让您使用向后兼容的@RestController
注释,并且它们通常会像以前一样返回ResponseEntity
。
没有兼容性功能的反应式 package 实现使用Router
和Handler
并且通常返回ServerResponse
。 有关 spring 的教程,请参阅构建反应式 RESTful Web 服务。
另请参阅 Spring WebFlux 指南,第1.4 章。 用于兼容性反应方式和1.5的注释控制器。 功能方式的功能端点。
如果您深入了解Annotated Controllers
代码,您会发现它使用了Functional Endpoints
代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.