首先看错误能看出来类型转换错误,我是在Controller层在地址上以斜杠的方式来取参数的时候报错的。
:
Failed to convert value of type '' to required type '';
代码:
@RequestMapping(value = "/deleteHealthExam/{healthExamId}/{healthExamDate}", method = )
public ResultDto deleteHealthExam(@PathVariable String healthExamId,
@PathVariable("healthExamDate") Date healthExamDate) {
return (healthExamId,healthExamDate);
}
原因:
healthExamDate我是以Date类型去接参数的,但是他默认是字符串类型,这里得需要类型转换一下。
解决方案:
添加@DateTimeFormat注解,让他类型转换成Date类型
@PathVariable("healthExamDate")
@DateTimeFormat(pattern="yyyy-MM-dd")
Date healthExamDate