@JsonFormat 如何在get请求中日期字段不报错还能使用
那就是直接提前转换了!!!不走注解@@@!!!
在controller注解下加入这个方法
@InitBinderpublic void initBinder(WebDataBinder binder){// Date 类型转换binder.registerCustomEditor(Date.class, new PropertyEditorSupport(){@Overridepublic void setAsText(String text){setValue(DateUtils.parseDate(text));}});}
报错!!!
@JsonFormat Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors<EOL>Field error in object
不过还是建议使用@DateTimeFormat可以适配各个请求入参,也比较灵活