WebFlux不返回给定状态

问题描述 投票:0回答:1

我正在将WebFlux与RestControllers一起使用。我的方法返回Mono>对象。我像这样将Mono映射到ResponseEntity中。

userService.flatMap(authenticationService::signUp)
    .map(user -> new ResponseEntity<>(user, HttpStatus.CREATED));

但是它仅返回200状态代码。无论我设置了什么状态代码。如何返回其他状态代码,例如201,204等?

spring-webflux project-reactor spring-restcontroller
1个回答
0
投票

使用Mono<ResponseEntity>作为获取设置状态的方法的返回类型。

© www.soinside.com 2019 - 2024. All rights reserved.