public class ArrayTest {

 private String[] names;
 
 /**
  * @param args
  */
 public static void main(String[] args) {
  ApplicationContext ctx = new ClassPathXmlApplicationContext("test/array/array-context.xml");
  ArrayTest at = (ArrayTest)ctx.getBean("at");
  
  for(int i = 0; i < at.getNames().length; i++){
   String s = at.getNames()[i];
   System.out.println("s=" + s);
  }
 }

 public String[] getNames() {
  return names;
 }

 public void setNames(String[] names) {
  this.names = names;
 }

}

 

使用list

<beans>
  <bean >
      <list>
        <value>aaa</value>
        <value>bbb</value>
      </list>
    </property>
  </bean>
</beans>

 

或者逗号分开

<beans>
  <bean >
    <value>aaa,bbb</value>
   </property>
  </bean>
</beans>

相关文章:

  • 2021-04-10
  • 2022-12-23
  • 2022-01-10
  • 2021-08-29
  • 2021-12-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-28
  • 2022-12-23
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案