json传递Date类型时间出错
来源:互联网 发布:淘宝差评在哪里写 编辑:程序博客网 时间:2024/06/05 12:47
做项目的时候,从前端传递时间参数到spring的controller,结果得到对象的时间结果不对(因为前端接收的格式是Date类型的而非String类型,错误如下图所示:
而其实完整的要传递的时间是:2015-07-31 15:07:48
解决办法是在controller加上如下代码:
@InitBinder protected void initBinder(HttpServletRequest request,ServletRequestDataBinder binder) throws Exception { DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); CustomDateEditor dateEditor = new CustomDateEditor(fmt, true); binder.registerCustomEditor(Date.class, dateEditor); }
转载请注明原址:http://blog.csdn.net/zheng911209/article/details/48179907
0 0
- json传递Date类型时间出错
- Date时间类型用json转化后显示[Object,Object]
- Json Date时间
- Date类型时间对比
- Json Date类型数据转 js date
- 获得date类型 系统时间
- date类型获取当前时间
- Date类型时间加一天
- Ext json传递Date数据问题
- mongodb 时间类型 date 时间戳等
- url中date类型参数的传递
- url中date类型参数的传递
- SpringMvc如何传递获取Date类型数据
- controller中使用@RequestBody,Java如何传递json对象访问接口,以及对象中的时间类型
- json返回date类型转为字符串
- java date类型转换为json
- 前台ajax请求Json,Date类型处理
- json返回date类型转为字符串
- CentOS 7 / RHEL 7 上安装 LAMP + phpMyAdmin
- Android为什么卡顿?为什么用起来不如iOS流畅
- Android快速启动方案设计原理(hibernation/HyperBoot)
- FPC查询网站
- Aspose.Words for .NET基本介绍以及功能介绍
- json传递Date类型时间出错
- ui
- java中String类型的最大长度
- Different Ways to Add Parentheses —— Leetcode(分治思想)
- 电源管理之android内核suspend to disk的实现(一)
- 通过unicorn Web Server加速Rails Server的速度
- 矩阵、向量求导法则
- 成功的启示
- ssh的信任关系的建立及原理