有下列路由
public RouterFunction<ServerResponse> doctorRoutes(DoctorHandler handler) {
return RouterFunctions.route()
.path("/doctors",b1 -> b1
.POST( handler::save)
.POST("/patient/{id}", accept(MediaType.APPLICATION_JSON), handler::addPatient)
.GET("/patients/{d_id}",accept(MediaType.APPLICATION_JSON),handler::getPatientsByDoctorId)
)
.build();
当请求/doctors/patient/153
时,没有正确进入addPatient
方法,而是进入/doctors
下的save
方法。解决方法:
public RouterFunction<ServerResponse> doctorRoutes(DoctorHandler handler) {
return RouterFunctions.route()
.path("/doctors",b1 -> b1
.POST("/patient/{id}", accept(MediaType.APPLICATION_JSON), handler::addPatient)
.GET("/patients/{d_id}",accept(MediaType.APPLICATION_JSON),handler::getPatientsByDoctorId)
.POST( handler::save)
)
.build();
来自为知笔记(Wiz)
标签:嵌套,routers,webFlux,accept,APPLICATION,JSON,handler,b1,id From: https://www.cnblogs.com/baiyifengyun/p/17060985.html