VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > 简明python教程 >
  • 注入集合类型数据

Person:

复制代码
package com.ly.spring;
import java.util.*;
public class Person {
    private String[] strArr;
    private List<String> strList;
    private Map<String,String> strMap;
    private Set<String> strSet;
    private Properties prop;
    public void setStrArr(String[] strArr) {
        this.strArr = strArr;
    }
    public void setStrList(List<String> strList) {
        this.strList = strList;
    }
    public void setStrMap(Map<String, String> strMap) {
        this.strMap = strMap;
    }
    public void setStrSet(Set<String> strSet) {
        this.strSet = strSet;
    }
    public void setProp(Properties prop) {
        this.prop = prop;
    }
    public String[] getStrArr() {
        return strArr;
    }
    public List<String> getStrList() {
        return strList;
    }
    public Map<String, String> getStrMap() {
        return strMap;
    }
    public Set<String> getStrSet() {
        return strSet;
    }
    public Properties getProp() {
        return prop;
    }
}
复制代码

配置文件:

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd">
    <bean id="person" class="com.ly.spring.Person">
        <property name="strArr">
            <array>
                <value>AAA</value>
                <value>BBB</value>
                <value>CCC</value>
            </array>
        </property>
        <property name="strList">
            <list>
                <value>DDD</value>
                <value>EEE</value>
                <value>FFF</value>
            </list>
        </property>
        <property name="strSet">
            <set>
                <value>GGG</value>
                <value>HHH</value>
                <value>III</value>
            </set>
        </property>
        <property name="strMap">
            <map>
                <entry key="k1" value="JJJ"></entry>
                <entry key="k2" value="KKK"></entry>
                <entry key="k3" value="LLL"></entry>
            </map>
        </property>
        <property name="prop">
            <props>
                <prop key="p1">MMM</prop>
                <prop key="p2">NNN</prop>
                <prop key="p3">OOO</prop>
            </props>
        </property>
    </bean>
</beans>
复制代码


相关教程