zoukankan      html  css  js  c++  java
  • Fill Value To List : XML Bean Property « Spring « Java

    Fill Value To List : XML Bean Property « Spring « Java

    ill Value To List

           
    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="collectionsExample" class="CollectionsBean">
        
        <property name="theList">
          <list>
            <value>red</value>
            <value>red</value>
            <value>blue</value>

          </list>
        </property>

      </bean>
      
      <bean id="curDate" class="java.util.GregorianCalendar"/>
      
    </beans>


    File: Main.java

    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    import java.util.Set;

    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;

    class Main {
      public static void main(String args[]) throws Exception {
        ApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
        
        
        CollectionsBean example = (CollectionsBeanctx.getBean("collectionsExample");
       System.out.println(example.getTheList());
      
      }
    }
    class CollectionsBean {
      
      private List theList;
      private Set theSet;
      private Map theMap;
      private Properties theProperties;
      
      public void setTheList(List theList) {
        this.theList = theList;
      }
      public List getTheList() {
        return theList;
      }
      
      public void setTheSet(Set theSet) {
        this.theSet = theSet;
      }
      public Set getTheSet() {
        return theSet;
      }
      
      public void setTheMap(Map theMap) {
        this.theMap = theMap;
      }
      public Map getTheMap() {
        return theMap;
      }
      
      public void setTheProperties(Properties theProperties) {
        this.theProperties = theProperties;
      }
      public Properties getTheProperties() {
        return theProperties;
      }
    }

  • 相关阅读:
    Java学习10——package和import
    第一次作业_031502532_吴智慧
    Java学习9——面向对象
    Java学习8——类(对象)之间的关系
    Java学习7——一些注意的地方
    Java学习5——标识符和关键字
    Zookeeper集群和HBase集群
    Zookeeper、HBase的伪分布
    hive学习笔记——表的基本的操作
    hive 学习笔记——表的入门操作和命令
  • 原文地址:https://www.cnblogs.com/lexus/p/2438922.html
Copyright © 2011-2022 走看看