美文网首页
controller接收时间字符串报错解决

controller接收时间字符串报错解决

作者: 勤劳的小仓鼠 | 来源:发表于2019-07-06 17:38 被阅读0次

今天在做项目的时候,前端传时间字符串到后台,后台接收报错,加上下面的方法在controller就好了

@InitBinder
protected void initBinder(WebDataBinder binder)
{
     SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
     binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}

相关文章

网友评论

      本文标题:controller接收时间字符串报错解决

      本文链接:https://www.haomeiwen.com/subject/kthmhctx.html