我正在努力从具有xml配置的类实例获取字段值。
方法getLabelName将LabelRequest作为参数,其中包含两个映射,一个称为labelMetaData。 applicationContext应该从实例LabelRequest读取值并将其设置为labelName。
private String getLabelName(LabelRequest labelRequest){
if(validation.metaDataValidation(labelRequest)){
ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
LabelName labelName = (LabelName) context.getBean("labelName");
System.out.println(labelName.getLabelName());
return labelName.getLabelName();
} return "error";
}
applicationContext.xml
<bean id="labelRequest" class="....LabelRequest"></bean>
<bean id="labelName" class="....LabelName">
<!--- for property name zzz from ClassTwo set value based on map called xxx with key 'test' inside ClassOne -->
<property name="labelName" value="#{
labelRequest.labelMetaData['labelType'] == 'ParcelLabele' ? 'returnString 1' : 'returnString 2' }"></property>
</bean>
</beans>