我对React式springwebflux完全陌生。我正在为post请求编写一个处理程序
接受json主体(员工id、姓名和角色),
使用id字段从数据库1获取更多员工详细信息,
返回带有其他属性(如年龄和部门)的员工json。。
我的路由器代码如下:
@Bean
-- something like this
POST("/empl/create").and(contentType(APPLICATION_JSON)), emplHandler::getMoreEmplDetails
柱体:
{
"id":"213"
"name": "John",
"role": "Manager"
}
模型类是这样的
Public class Employee
{
Public string id;
Public string name;
Public string role;
Public string dept;
Public int age;
}
处理程序代码如下
public Mono<ServerResponse>getMoreEmplDetails(ServerRequest request){
Mono<Employee> np = request.bodyToMono(Employee.class);
np.subscribe(x-> System.out.println("Print Body"+x));
//This returns a MonoOnErrorResume
/* More code should follow here*/
Return Mono.empty()// THIS IS TEMPORARY. I WANT TO RETURN COMPLETE EMPL JSON WITH AGE AND DEPT HERE
};
问题是我想打印用于调试目的的正文,但要像处理程序代码中的注解所示,继续获取mononerrorresume。我如何确保我的身体被处理方法接收良好??
1条答案
按热度按时间vdzxcuhz1#
我可以用Map记录结果。