Spring 在 ResponseEntity 中自动包装其余控制器响应
Spring automatically wrap rest controller response in ResponseEntity
这是我想要实现的目标:
我有很多 spring 休息反应控制器 returning 各种对象,如 Mono、Flux
我想将所有这些响应包装在一个 ResponseEntity 中,所以总是 return 类似于:
Mono<ResponseEntity<MyObjects>>
有什么建议吗?
只需在控制器上使用 @ResponseBody
注释
When you use the @ResponseBody annotation on a method, Spring converts the return value and writes it to the http response automatically. Each method in the Controller class must be annotated with @ResponseBody.
这是我想要实现的目标: 我有很多 spring 休息反应控制器 returning 各种对象,如 Mono、Flux
我想将所有这些响应包装在一个 ResponseEntity 中,所以总是 return 类似于:
Mono<ResponseEntity<MyObjects>>
有什么建议吗?
只需在控制器上使用 @ResponseBody
注释
When you use the @ResponseBody annotation on a method, Spring converts the return value and writes it to the http response automatically. Each method in the Controller class must be annotated with @ResponseBody.