Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 如何在Spring引导Rest调用中传递日期类型的值?_Spring Boot_Rest_Postman - Fatal编程技术网

Spring boot 如何在Spring引导Rest调用中传递日期类型的值?

Spring boot 如何在Spring引导Rest调用中传递日期类型的值?,spring-boot,rest,postman,Spring Boot,Rest,Postman,我在Spring Boot中有一个RestController的类模型对象类@RequestBody @Data class User { private String name; private Date dob; } 我使用以下JSON主体从postman调用此API { "name" : "Michael", "dob" : "13/09/19" } 我收到状态为200 OK的消息 '分析正文时出错。请使用正确的有效负载进行尝试。” 我的数据没有被提交。

我在Spring Boot中有一个RestController的类模型对象类@RequestBody

@Data
class User {
      private String name;
      private Date dob;
 }
我使用以下JSON主体从postman调用此API

{
 "name" : "Michael",
 "dob" : "13/09/19"
 }
我收到状态为200 OK的消息

'分析正文时出错。请使用正确的有效负载进行尝试。”


我的数据没有被提交。我知道问题在于日期,如何发送正确的日期?

您可以尝试对dob字段进行如下注释:

@JsonFormat(pattern="dd/MM/yy")
private Date dob;

来源:

您仍然有这个问题吗?