系统吧 专业的电脑操作系统,支持重装各种原版系统xp/win7/win8/win10 这个系统怎么样?试试系统吧系统,体验办公系统畅快愉悦感。 各种电脑系统安装过程一样,神一般的畅快!
-->
当前位置:主页 > 电脑技术 >

老司机搞定运用 PropertyEditorRegistrar

作者:宋韵瑜 分类:电脑技术 发布时间:2017-09-19 18:04:36

电脑现已成为我们工作、生活和娱乐必不可少的工具了,在使用电脑的过程中,可能会遇到运用 PropertyEditorRegistrar的问题,如果我们遇到了运用 PropertyEditorRegistrar的情况,该怎么处理怎么才能解决运用 PropertyEditorRegistrar带来的困扰呢,对于这样的问题其实我们只需要springIntelliJ使用Spring容器注册属性编辑器的另一种机制是创建和使用PropertyEditorRegistrar。当您需要在几种不同情况下使用同一组属性编辑器时,此接口特别有用。您可以编写相应的注册商,并在...

电脑现已成为我们工作、生活和娱乐必不可少的工具了,在使用电脑的过程中,可能会遇到运用 PropertyEditorRegistrar的问题,如果我们遇到了运用 PropertyEditorRegistrar的情况,该怎么处理怎么才能解决运用 PropertyEditorRegistrar带来的困扰呢,对于这样的问题其实我们只需要springIntelliJ使用Spring容器注册属性编辑器的另一种机制是创建和使用PropertyEditorRegistrar。当您需要在几种不同情况下使用同一组属性编辑器时,此接口特别有用。您可以编写相应的注册商,并在每种情况下重复使用它。PropertyEditorRegistrar实例与一个名为PropertyEditorRegistry的接口一起工作,该接口由SpringBeanWr这样就解决了这样的问题,接下来给大家带来运用 PropertyEditorRegistrar的详细操作步骤。

工具/原料

spring
IntelliJ

方法/步骤

使用Spring容器注册属性编辑器的另一种机制是创建和使用PropertyEditorRegistrar。当您需要在几种不同情况下使用同一组属性编辑器时,此接口特别有用。您可以编写相应的注册商,并在每种情况下重复使用它。

老司机搞定运用 PropertyEditorRegistrar

PropertyEditorRegistrar实例与一个名为PropertyEditorRegistry的接口一起工作,该接口由SpringBeanWrapper(和DataBinder)实现。PropertyEditorRegistrar当与CustomEditorConfigurer一起使用时,实例特别方便,它暴露了一个名为的属性setPropertyEditorRegistrars(..)。以这种方式PropertyEditorRegistrar添加到a的实例CustomEditorConfigurer可以很容易地与之共享DataBinder和Spring MVC控制器。

老司机搞定运用 PropertyEditorRegistrar

此外,它避免了在自定义编辑器上进行同步的需要:APropertyEditorRegistrar期望PropertyEditor为每个bean创建尝试创建新的实例。

老司机搞定运用 PropertyEditorRegistrar

以下示例显示如何创建自己的PropertyEditorRegistrar实现:

老司机搞定运用 PropertyEditorRegistrar

在实现该registerCustomEditors(..)方法时,它会创建每个属性编辑器的新实例。

老司机搞定运用 PropertyEditorRegistrar

示例显示了如何配置CustomEditorConfigurer和注入我们的实例CustomPropertyEditorRegistrar:

老司机搞定运用 PropertyEditorRegistrar

PropertyEditorRegistrars结合使用数据绑定Controllers(例如SimpleFormController)可以非常方便。以下示例PropertyEditorRegistrar在initBinder(..)方法的实现中使用

老司机搞定运用 PropertyEditorRegistrar

这种 PropertyEditor 注册方式可以导致简洁的代码(实现 initBinder(..) 只有一行),并允许将通用 PropertyEditor 注册代码封装在一个类中,然后 Controllers 根据需要共享 。

老司机搞定运用 PropertyEditorRegistrar

xp 更多>>
win7 更多>>
win8 更多>>
win10 更多>>
U盘 更多>>
电脑技术 更多>>
网站地图 | 豫ICP备2021035069号-4 | 友情链接qq:191064436
系统吧

版权所有 © 2012-2023 系统吧 免责声明:本站资源均收集于互联网,其著作权归原作者所有,如果有侵犯您权利的资源,请来信告知,我们将及时删除相应资源。