因为springmvc默认是date参数不能为空,传参时如果想为空就可以在Controller【Action】处理页面写上以下代码就好
import org.springframework.web.bind.WebDataBinder;
@org.springframework.web.bind.annotation.InitBinder
public void InitBinder(WebDataBinder dataBinder)
{
dataBinder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
public void setAsText(String value) {
try {
setValue(new SimpleDateFormat("yyyy/MM/dd").parse(value));
} catch(Exception e) {
setValue(null);
}
}
public String getAsText() {
return new SimpleDateFormat("yyyy/MM/dd").format((Date) getValue());
}
});
}