小编Ami*_*ali的帖子

如何以 POST 方法在 REST API 中发送日期

我正在尝试使用 Spring 支持构建 RESTful Web 服务。当我尝试发送 POST 请求时出现以下异常。

输入:

POST    http://localhost:8080/InventoryDemo/item
Run Code Online (Sandbox Code Playgroud)

在 JSON 有效负载中:

{"materialId":"ID02","materialName":"Material_2","materialCategory":"LIQUID","currency":"RUPEES","unitCostInCurrency":2200.0,"quantityLevel":1000,"quantityAtDate":"2016-04-11","warehouseName":"WareHouse_2"}
Run Code Online (Sandbox Code Playgroud)

例外:

WARNING: Handler execution resulted in exception: Could not read document: Can not instantiate value of type [simple type, class java.time.LocalDate] from String value ('2016-04-11'); no single-String constructor/factory method
 at [Source: java.io.PushbackInputStream@378ace07; line: 1, column: 146] (through reference chain: com.psl.inventory.model.InventorySystemModel["quantityAtDate"]); nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class java.time.LocalDate] from String value ('2016-04-11'); no single-String constructor/factory method
 at [Source: java.io.PushbackInputStream@378ace07; …
Run Code Online (Sandbox Code Playgroud)

java rest spring json localdate

6
推荐指数
2
解决办法
3万
查看次数

标签 统计

java ×1

json ×1

localdate ×1

rest ×1

spring ×1