Spring mvc Spring 3.1与列表绑定的表格<;日期>;

Spring mvc Spring 3.1与列表绑定的表格<;日期>;,spring-mvc,Spring Mvc,我有一个表单对象 public class TestForm { private long id; private List<Date> dates; // getters and setters for the above } 我的表格 <form name="abc" method="post" action="assignDummy.htm"> <input type="text" name="id" value="1000"> <input

我有一个表单对象

public class TestForm {
 private long id;
 private List<Date> dates;
// getters and setters for the above
}
我的表格

<form name="abc" method="post" action="assignDummy.htm">
<input type="text" name="id" value="1000">
<input type="text" name="dates[0]" value="4500000">
<input type="submit">
</form>

我得到以下错误

无法将“java.lang.String”类型的属性值转换为 属性“dates[0]”所需的类型为“java.util.Date”;嵌套 例外是 org.springframework.core.convert.ConversionFailedException:未能 将值的类型从java.lang.String转换为java.util.Date '4500000'; 嵌套异常为java.lang.IllegalArgumentException“

感谢您的帮助。
提前感谢

您试图在不转换字符串的情况下将其放入日期,因此它会崩溃。 必须使用自定义属性编辑器才能将输入字符串转换为日期

尝试添加控制器

 @InitBinder
    public void initBinder(WebDataBinder binder) {
        CustomDateEditor editor = new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true);
        binder.registerCustomEditor(Date.class, editor);
    }

谢谢,我发现默认的日期格式是YYYY/MM/dd。所以我会这样使用它。。
 @InitBinder
    public void initBinder(WebDataBinder binder) {
        CustomDateEditor editor = new CustomDateEditor(new SimpleDateFormat("MM/dd/yyyy"), true);
        binder.registerCustomEditor(Date.class, editor);
    }