SpringMVC接收String类型时间数值(实体类是Date)转换

2021-09-28 12:15

阅读:950

标签:实体   custom   set   for   new   类型   span   rcu   接收   SpringMVC接收String类型字符串 bean实体是Date 加入bind @InitBinder public void initBinder(WebDataBinder binder) { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); // SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd‘T‘HH:mm:ss.SSS Z"); dateFormat.setLenient(false); binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true)); //true:允许输入空值,false:不能为空值 } 对单独字符串以及实体类bean接收都起效SpringMVC接收String类型时间数值(实体类是Date)转换标签:实体   custom   set   for   new   类型   span   rcu   接收   原文地址:https://www.cnblogs.com/ukzq/p/12094445.html


评论


亲,登录后才可以留言!