使用Spring mvc-3。我正在编写一个自定义转换器,它需要访问注册到ConversionService的其他转换器。将ConversionService注入自定义转换器
我该如何做到这一点?我试着写我的自定义转换器:
class CustomConverter<X, Y>{
@Autowired ConversionService service;
//+getter & setters of service
public Y convert(X input){
// I need access to service to lookup simple conversions such as
// String array to Long array etc..
}
}
而且我注册了我的自定义转换器的applicationContext.xml通过
<bean id="conversionService" class="org.springframework.context.support.ConversionServiceFactoryBean">
<property name = "converters">
<list>
<bean class="CustomConverter"/>
</list>
</property>
</bean>
然而,春天拒绝服务注入到我的CustomConverter(其始终为空)。我怎样才能做到这一点?
谢谢!
我得出同样的结论!谢谢。 – Ajay
这个解决方案的问题是MyCustomConverter不是由spring容器管理的 – Gleeb