开发者

Questions about property editor (customEditor) not being applied?

开发者 https://www.devze.com 2023-02-01 01:55 出处:网络
I\'m using Spring mvc 3 and I\'d like to format a field. Per a suggestion I\'d like to move it to a p开发者_Python百科roperty editor.

I'm using Spring mvc 3 and I'd like to format a field. Per a suggestion I'd like to move it to a p开发者_Python百科roperty editor.

However it doesn't seem to be applied. I did:

@InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(String.class, "mobileNumber", new MobileNumberEditor(false));
    }

Where mobileNumber is a variable of my User object. I've also tried user.mobileNumber but that doesn't seem to work either?

I could probably register (User.class,new UserEditor(false)) but that seems to be a bit of a roundabout way.

0

精彩评论

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