个人做网站时不要做什么样的网站,百度网站排名全掉,微信企业邮箱怎么注册,直接从厂家拿货的平台前端上传日期时间数据到后台时#xff0c;上传失败我这里是用里存放时间#xff0c;上传到后台的controller方法时#xff0c;参数类型是java.util.Date#xff0c;发现没有到controller方法里面。报错#xff1a;不能将String转成Date。我想错误的原因是前端传上来的是St…前端上传日期时间数据到后台时上传失败我这里是用里存放时间上传到后台的controller方法时参数类型是java.util.Date发现没有到controller方法里面。报错不能将String转成Date。我想错误的原因是前端传上来的是String而controller方法里用Date接收因为转换失败而一直不能把数据传到controller。一开始的错误代码从到取消确定预约function bookCar() {alert($(#book_car_form).serialize());$.post(front/order/bookCar, $(#book_car_form).serialize(), function (data) {if (data 1) {alert(预约成功);} else {alert(预约失败);}window.location.reload();});}controllerRequestMapping(bookCar)public String bookCar(Integer carId, Date startUseCarDatetime, Date endUseCarDatetime, HttpSession session) {//...}解决方法方法1在controller方法里面的参数的类型都改为StringRequestMapping(bookCar)public String bookCar(Integer carId, String startUseCarDatetime, String endUseCarDatetime, HttpSession session) {//...}方法2如果想用一个pojo接收可以在Date属性加上DateTimeFormat标签RequestMapping(bookCar)public String bookCar(BookCarQueryVo bookCarQueryVo, HttpSession session) {//...}public class BookCarQueryVo {private Integer carId;DateTimeFormat(patternyyyy-MM-dd HH:mm:ss)private Date startUseCarDatetime;DateTimeFormat(patternyyyy-MM-dd HH:mm:ss)private Date endUseCarDatetime;public Integer getCarId() {return carId;}public void setCarId(Integer carId) {this.carId carId;}public Date getStartUseCarDatetime() {return startUseCarDatetime;}public void setStartUseCarDatetime(Date startUseCarDatetime) {this.startUseCarDatetime startUseCarDatetime;}public Date getEndUseCarDatetime() {return endUseCarDatetime;}public void setEndUseCarDatetime(Date endUseCarDatetime) {this.endUseCarDatetime endUseCarDatetime;}}如果有错请大家指正谢谢。