在对 JAX-RS 控制器的 PUT 请求中将 LocalDateTime 设置为 Null

LocalDateTime being set to Null in PUT Request to JAX-RS Controller

我试图在方法的请求参数中传递 LocalDateTime,但它始终记录 null。请帮我弄清楚我在这里做错了什么:

@Path("/book/workOrderId/{workOrderId}")
@PUT
    public Response bookWorkOrder(@Context HttpHeaders headers, @PathParam("countryCode") String countryCode,
            @PathParam("workOrderId") int workOrderId,
            @QueryParam("reasonId") int reasonId,
            @RequestParam(value = "dateTime") @DateTimeFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss")  LocalDateTime dateTime

    ) throws CDException {
    
        logger.debug("dateTime outside if::" + dateTime);
        return Response.ok(true).build();
}

输出:

22:32:27.659 [http-nio-8300-exec-2] DEBUG c.c.t.i.e.v.impl.WorkorderController - dateTime outside if::null

这对我有用:

@PUT
    public Response bookWorkOrder(@Context HttpHeaders headers, @PathParam("countryCode") String countryCode,
            @PathParam("workOrderId") int workOrderId, @QueryParam("bookingTime") String bookingTime,
            @QueryParam("reasonId") int reasonId) throws CDException {
        LocalDateTime localDateTime = LocalDateTime.parse(bookingTime, DateTimeFormatter.ISO_DATE_TIME);
        logger.debug("bookingTime:: {}", bookingTime);
return Response.ok(true).build();

}