spring自定义属性编辑器使用dome
来源:互联网 发布:2017年10月非农数据 编辑:程序博客网 时间:2024/06/05 19:11
Spring xml配置
<bean class="org.springframework.beans.factory.config.CustomEditorConfigurer">
<property name="propertyEditorRegistrars">
<list>
<ref bean="customCollectionEditorRegistrar"/>
</list>
</property>
</bean>
<bean id="customCollectionEditorRegistrar" class="com.focustech.channelfy.product.service.factoryBean.CustomCollectionEditorRegistrar">
<property name="factoryListEditor" ref="factoryListEditor"/>
</bean>
<bean id="factoryListEditor" class="org.springframework.beans.propertyeditors.CustomCollectionEditor">
<constructor-arg name="collectionType" value="com.focustech.channelfy.product.service.factoryBean.FactoryArrayList" type="java.lang.Class"/>
</bean>
CustomCollectionEditorRegistrar自定义注册机
public class CustomCollectionEditorRegistrar implements PropertyEditorRegistrar {
private PropertyEditor factoryListEditor;
public void setFactoryListEditor(PropertyEditor factoryListEditor) {
this.factoryListEditor = factoryListEditor;
}
@Override
public void registerCustomEditors(PropertyEditorRegistry registry) {
registry.registerCustomEditor(FactoryList.class, factoryListEditor);
}
}
FactoryArrayList需要自定属性
public class FactoryArrayList<T extends MatchingBean<K>,K> extends ArrayList<T> implements FactoryList<T,K> {
public T getBean(K k) throws NoFindClassException {
Iterator<T> iterator = this.iterator();
while (iterator.hasNext()){
T next = iterator.next();
if (next.getBean(k)){
return next;
}
}
throw new NoFindClassException();
}
}
自定属性实现接口
public interface FactoryList<E extends MatchingBean<K>,K> extends List<E> {
E getBean(K var1) throws NoFindClassException;
}
自定属性实现接口
public interface MatchingBean<T> {
boolean getBean(T t);
}
阅读全文
0 0
- spring自定义属性编辑器使用dome
- Spring自定义属性编辑器PropertyEditorSupport + 使用CustomEditorConfigurer注册属性编辑器
- Spring自定义属性编辑器CustomEfitorConfigurer使用实例
- Spring自定义属性编辑器
- Spring自定义属性编辑器
- spring自定义属性编辑器
- Spring自定义属性编辑器
- Spring-----自定义属性编辑器
- 详解spring自定义属性编辑器
- Spring整理3 -- 自定义属性编辑器
- spring自定义属性编辑器的配置
- spring中自定义属性编辑器CustomEditorConfigurer
- Spring攻略笔记-7 自定义属性编辑器
- spring中自定义属性编辑器CustomEditorConfigurer
- spring中自定义属性编辑器的实现
- spring中自定义属性编辑器CustomEditorConfigurer
- spring中自定义属性编辑器CustomEditorConfigurer
- spring中自定义属性编辑器CustomEditorConfigurer
- IP路由流程很详细的例子
- 程序员的自我修养--计算机网络
- Servlet 返回JSON
- TabLayout的操作实现
- 网络通信 Socket 实现TCP
- spring自定义属性编辑器使用dome
- SVN如何解决冲突
- postgresql日志补充
- iT世界的真与实——学习心得
- CountDownLatch实现原理
- 【矩阵幂的和+矩阵快速幂】Power of Matrix UVA
- SSD Tensorflow:UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start
- codeforces 862B (二分图 dfs )之 Mahmoud and Ehab and the bipartiteness
- 什么是Hadoop