• String类型日期自动转Date数据类型


    表单提交时候"Failed to convert property value of type [java.lang.String] to...

    需要在核心控制器Controller加这个

    @InitBinder

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

    就能实现String类型的日期格式向Date类型的转换了!!!

    前端部分的代码如下:

    <tr>
      <td>结账时间</td>
      <td>
        <input type="text" name="payTime"
              value='  <fmt:formatDate value="${ orderInfo.payTime }"
              pattern="yyyy-MM-dd HH:mm:ss" />  '>
      </td>
    </tr>

  • 相关阅读:
    操作系统要点总结
    ARP的通信过程
    判断网段、子网、网络号
    C++要点总结
    枚举类型
    C指针总结
    C运算符总结
    替换空格
    WCF编写时候的测试
    WCF创建到使用到发布
  • 原文地址:https://www.cnblogs.com/chenglaoshi/p/11602216.html
Copyright © 2020-2023  润新知