【发布时间】:2010-12-09 16:02:24
【问题描述】:
我正在使用休眠验证器来验证我的表单。 我有一个“问题”,即第 14 个月的第 9 号成为明年的第二个月。 (只是一个场景示例)。
我想知道如何防止默认转换,而是为其显示自定义错误消息。
如果我的自定义编辑器抛出 IllegalArgumentException,还有人知道如何显示适当的消息吗?
@InitBinder
public void initBinder(WebDataBinder binder) {
CustomDateEditor editor = new CustomDateEditor(new SimpleDateFormat("dd/MM/yyyy"), true);
binder.registerCustomEditor(Date.class, editor);
}
我注册了一个 customEditor,因为 spring-portlet-mvc 的绑定存在一些问题。
【问题讨论】:
标签: spring-mvc hibernate-validator