1
我正在使用hibernate驗證器來驗證我的表單。 我有第14個月的第9個月成爲明年第2個月的「問題」。 (僅僅是一個場景的例子)。Hibernate驗證器:如何處理翻滾? (28/14/2009變成28/2/2010)
我想知道如何防止默認轉換,而是顯示自定義錯誤消息。
有沒有人也知道如果我的自定義編輯器拋出IllegalArgumentException異常,我可以顯示一個appropenate消息?
@InitBinder
public void initBinder(WebDataBinder binder) {
CustomDateEditor editor = new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true);
binder.registerCustomEditor(Date.class, editor);
}
我註冊了一個自定義編輯器,因爲spring-portlet-mvc在綁定時遇到了一些問題。
@jack:實際發生的 - 翻轉或`IllegalArgumentException` ? – axtavt 2010-12-10 13:08:03