Spring3控制器中的自定义数据绑定器

Spring3控制器中的自定义数据绑定器,spring,spring-mvc,controller,spring-3,Spring,Spring Mvc,Controller,Spring 3,在控制器中注册自定义数据绑定器的Spring2方法是重写扩展spring控制器的createBinder方法。Spring3是如何做到这一点的?我们使用@Controller注释,因此没有可以重写的钩子。我会期待像“@CreateBinder”这样的东西 搜索网页没有多大帮助。我只找到了相关的线索 要明确这一点:这与设置属性编辑器无关。这可以通过@InitBinding实现。使用@InitBinder注释 @InitBinder public void initBinderAll(WebData

在控制器中注册自定义数据绑定器的Spring2方法是重写扩展spring控制器的createBinder方法。Spring3是如何做到这一点的?我们使用@Controller注释,因此没有可以重写的钩子。我会期待像“@CreateBinder”这样的东西

搜索网页没有多大帮助。我只找到了相关的线索


要明确这一点:这与设置属性编辑器无关。这可以通过@InitBinding实现。

使用@InitBinder注释

@InitBinder
public void initBinderAll(WebDataBinder binder) {
    binder.registerCustomEditor(Country.class,  new CountryEditor());
}

Simon

使用@InitBinder注释

@InitBinder
public void initBinderAll(WebDataBinder binder) {
    binder.registerCustomEditor(Country.class,  new CountryEditor());
}
西蒙