开发者

spring 3 propertyeditor throws exception

开发者 https://www.devze.com 2023-01-13 12:45 出处:网络
New Problem: I register / bind my custom property editor and get an java.lang.IllegalArgumentException 开发者_C百科- as expected.

New Problem:

I register / bind my custom property editor and get an java.lang.IllegalArgumentException 开发者_C百科- as expected. The problem: I do not know how to create a custom error message if binding fails.

Any idea? THX!

@InitBinder( { "playerCreationBean" } )
protected void initBinder( final WebDataBinder binder )
{
   binder.registerCustomEditor(Date.class, new DatePropertyEditor());    
}


axtavt is right. If you have a message bundle in your application (ie, messages.properties in your classpath, being used by a MessageSource implementation) spring can automatically use the friendly message in the bundle. The message 'typeMismatch' is just one of a number of default messages that are used by the binding framework, depending on the name of the object being bound as well as the property being bound to. You can use a debugger to inspect the errors instances after binding and find which messages are created by default when a binding exception occurs. I've found that the Spring Documentation is a bit lacking when it comes to the default message names that are generated.

0

精彩评论

暂无评论...
验证码 换一张
取 消