PropertySetting: String Array : XML Bean Property « Spring « Java






PropertySetting: String Array

File: context.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"
    "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="testBean" class="PropertyEditorTestBean">
    <property name="myStrings" value="A,B,C,D"/>

  </bean>
</beans>


File: Main.java

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.core.io.ClassPathResource;

public class Main {

  public static void main(String[] args) throws Exception {
    BeanFactory beanFactory = new XmlBeanFactory(new ClassPathResource("context.xml"));
    PropertyEditorTestBean testBean = (PropertyEditorTestBean) beanFactory.getBean("testBean");

    System.out.println(testBean.getMyStrings().length);
  }
}

class PropertyEditorTestBean {
  private String[] myStrings;

  public String[] getMyStrings() {
    return myStrings;
  }

  public void setMyStrings(String[] myStrings) {
    this.myStrings = myStrings;
  }
}




           
       








Spring-PropertySettingStringArray.zip( 2,599 k)

Related examples in the same category

1.Property Setting: URL
2.Property Setting: Stream From URL
3.Property Setting: Properties
4.Property Setting: Integer
5.Property Setting: File
6.Property Setting: Class type
7.Property Setting: Byte Array
8.Property Setting: Boolean
9.Property Setting: BigDecimal
10.Properties Setting: Date
11.Load property File In Context
12.lazy init
13.Fill Value To List
14.Fill Map
15.Fill Set
16.Fill Properties
17.Fill List To Another List
18.Fill Calendar Object To List
19.Create List Map In Context
20.Bean Injection: Map
21.Bean Injection Collection: Set
22.Bean Injection: Collection Properties
23.Bean Injection Collection: Map
24.Bean Injection Collection: List