1.测试postman 向数据库添加优惠券信息报错
原始Body:
{
"shopId": 1,
"title": "100元代金券",
"subTitle": "周一至周五均可使用",
"rules": "全场通用\\n无需预约\\n可无限叠加\\n不兑现、不找零\\n仅限堂食",
"payValue": 8000,
"actualValue": 10000,
"type": 1,
"stock": 100,
"beginTime": "2022-01-26T10:09:17",
"endTime": "2022-01-26T24:09:04"
}
20:51:11.991 ERROR 22384 — [nio-8081-exec-2] com.hmdp.config.WebExceptionAdvice : org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Current token (VALUE_STRING) not numeric, can not use numeric value accessors; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Current token (VALUE_STRING) not numeric, can not use numeric value accessors
at [Source: (PushbackInputStream); line: 10, column: 17] (through reference chain: com.hmdp.entity.Voucher[“beginTime”])

原因是我们在JacksonConfig.java中配置了
// 从 JSON 中读取时间戳(毫秒值)
long timestamp = p.getLongValue();// 前端要传时间戳是Long
原来是要传时间戳,不能传"2022-01-26T10:09:17"这个日期了。
修改body为:
{
"shopId": 1,
"title": "100元代金券",
"subTitle": "周一至周五均可使用",
"rules": "全场通用\\n无需预约\\n可无限叠加\\n不兑现、不找零\\n仅限堂食",
"payValue": 8000,
"actualValue"

最低0.47元/天 解锁文章

被折叠的 条评论
为什么被折叠?



