@GetMapping("/test")
public ResponseResult docList(QueryListParam queryListParam) {
return testService.queryList(queryListParam);
}
@Data
public class QueryListParam implements Serializable {
private String name;
private Date startTime;
private Date endTime;
}
GET请求直接传递 startTime=2020-01-01 01:10:00 是接收不到了,后台会报错,需要在bean中Date类型的属性上添加注解@DateTimeFormat(pattern = “yyyy-MM-dd HH:mm:ss”)
该注解是org.springframework.format.annotation下的
@Data
public class QueryListParam implements Serializable {
private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date startTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date endTime;
}



