码迷,mamicode.com
首页 > 其他好文 > 详细

注入集合类型数据

时间:2020-02-19 19:26:56      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:pre   person   mmm   oid   enc   数据   ret   package   util   

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>

 

注入集合类型数据

标签:pre   person   mmm   oid   enc   数据   ret   package   util   

原文地址:https://www.cnblogs.com/liuyang-520/p/12332443.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!