Apple iPhone 11 (A2223) 128GB 黑色 移动联通电信4G手机 双卡双待
4999元包邮
去购买 >
在Spring-MVC中
映射类声明变量前,加入此注解
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss" )
原因是:页面将数据传到后台,是以字符串的形式。所以时间格式会出错。加上此注解,后台可解析时间格式的字符串。但是后台传到前台,前台没办法解析。需要做如下操作。
Date.prototype.format = function (format) {
var o = {
"M+": this.getMonth() + 1, // month
"d+": this.getDate(), // day
"h+": this.getHours(), // hour
"m+": this.getMinutes(), // minute
"s+": this.getSeconds(), // second
"q+": Math.floor((this.getMonth() + 3) / 3), // quarter
"S": this.getMilliseconds()
// millisecond
};
if (/(y+)/.test(format))
format =