There is a type conversion problem between the page and the front controller. If you want to implement a type conversion yourself:
public class StringDateConvert implements Converter<String, Date> {
@Override
public Date convert(String source) {
//1.判断是否为空
if (source == null) {
throw new RuntimeException("请输入正常日期");
}
System.out.println("首先,写实现converter类的类,其次,将其加入springMvVC中,最后,通过MvC启动该类的使用");
//2.自定义
DateFormat df = new SimpleDateFormat("yyyy-MM-DD");
try {
return df.parse(source);
} catch (ParseException e) {
throw new RuntimeException("w,跳转错误");
}
}
}
[2. Configuration registration ] 3. Join the container and enable