在开发过程中遇见了,使用SpringMVC接受前台数据的时候,如果对象中有date类型,就会出现类型转化异常。
解决办法:使用InitBinder。
@InitBinder
public void intDate(WebDataBinder dataBinder){
dataBinder.addCustomFormatter(new DateFormatter("yyyy-MM-dd HH:mm:ss"));
}
在Controller层中写入以上代码即可解决。