Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date

Prerequisite description: The date defined by layui is passed to the background to return the error in the title, and spring boot is used in the background.
Solution: add @DateTimeFormat (pattern = “yyyy-MM-dd hh: mm: ss”) to the entity class

The controller must add: @Valid and BindingResult BindingResult
data format passed to the background: kfRepairDate: 2018-10-22 10:55:32
Controller:

@ResponseBody
	@RequestMapping(value = "/update", method = RequestMethod.POST)
	public Boolean update(@Valid TKfRepair em,BindingResult BindingResult) {
		return t.updateById(em);
	}

front end:

							var ins22 = laydate.render({
								elem : '#kfRepairDate',
								min : '2016-10-14',
								max : '2080-10-14',
								type : 'datetime'
							});

Entity class:

	@DateTimeFormat(pattern="yyyy-MM-dd hh:mm:ss")
	@TableField(value="kf_repair_date")
	private Date kfRepairDate;

Thanks https://q.cnblogs.com/q/93720/ Chen Wuwen

Published 100 original articles · Like 106 · Visit 270,000+

Guess you like

Origin blog.csdn.net/lglglgl/article/details/83270440