渺沧海一粟667
2021-08-30 20:54
采纳率: 71.4%
浏览 88
已结题

java.sql.Time 类型使用问题

有没有人用java.sql.Time能请教一下time怎么用吗。我前端用json传的。结果转换报400. 用Time类型有什么解决方案吗

报错400

 警告 [http-nio-8080-exec-6] org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.logException Resolved [org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot construct instance of `java.sql.Time`, problem: `java.lang.IllegalArgumentException`; nested exception is com.fasterxml.jackson.databind.exc.ValueInstantiationException: Cannot construct instance of `java.sql.Time`, problem: `java.lang.IllegalArgumentException`
 at [Source: (PushbackInputStream); line: 1, column: 79] (through reference chain: com.neusoft.meeting.pojo.Appointment["startTime"])]

实体类加了注解
img

controller用@RequestBody接收

img

ajax

                        $.ajax({
                            url: '/orderAppointment',
                            type: 'post',
                            dataType: 'text',
                            contentType:'application/json;charset=utf-8',
                            data: JSON.stringify({
                                'userUid': userUid,
                                'roomUid': roomUid,
                                'appointmentDate': appointmentDate,
                                'startTime': startTime,
                                'endTime': endTime,
                                'state': state
                            }),
                            success: function (res) {
                                if (res == "success") {
                                    layer.msg('预约成功!');
                                } else {
                                    layer.msg("对不起,预约失败.");
                                }
                            }
                        });

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题