I now use Spring MVC to develop and meet one strange problem . I have one Command class Employee which has one property named birthDay.My
Employee class likes :
Employee {
private java.util.Date birthDay;
public void setBirthDay ( java.util.Date birthday ){
this.birthDay = birthDay;
}
public java.util.Date getBirthDay ( ){
return this.birthDay;
}
In my formController class AddEmployeeFormController which extends SimpleFormControlle I registed CustomDateEditor as such:
protected void initBinder(HttpServletRequest request,
ServletRequestDataBinder binder) throws Exception { java.text.SimpleDateFormat dateFormat = new java.text.SimpleDateFormat("yyyy/MM/dd");
dateFormat.setLenient(true);
binder.registerCustomEditor(java.util.Date.class, null ,new CustomDateEditor(dateFormat, true));
}
my formView jsp file is:
<tr>
<td height="20" width = "30%" ><fmt:message key = "employee.birthday" />:</td>
<td height="20" width = "70%" align = "left" >
<spring:bind path="employee.birthday">
<input name = "birthday" type = "text" value="<c:out value="${status.value}"/>">
</spring:bind><font color = "red" >yyyy/MM/dd</font></td>
</tr>
when I input "2005/03/08" , it don't throw exception but say there is binding error. I print the BinderException's content:
Data binding errors: 1
errors.getMessage():BindException: 1 errors; Field error in object 'employee' on field 'birthday': rejectedValue=[Tue Mar 08 00:00:00 CST 2005]; codes=[errors.date.employee.birthday,errors.date.birthday ,errors.date.java.util.Date,errors.date]; arguments=[(org.springframework.context.support.DefaultMessag eSourceResolvable)[codes=[employee.birthday]; arguments=[null]; defaultMessage=[employee.birthday]], (java.lang.String)[yyyy/MM/dd]]; defaultMessage=[errors.date].
I really don't what's wrong with this. Who can help me ? Thanks very much.
Although I study carefully the content of :http://forum.springframework.org/viewtopic.php?t=537. I can't
get out some solution.


Reply With Quote
