zoukankan      html  css  js  c++  java
  • 注入集合类型数据

    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>
  • 相关阅读:
    Java修炼之道--I/O
    配置tomcat资源文件软连接
    配置tomcat按天输出日志文件
    Ubuntu 安装rabbitmq
    Ubuntu下 JDK、tomcat、redis离线安装
    Nginx+tomcat负载均衡环境搭建
    Tomcat性能调优及性能测试工具配置
    Tomcat搭建https并与APR模式兼容
    IDEA开发工具小技巧整理
    Ubuntu下Nginx+fastDFS环境安装
  • 原文地址:https://www.cnblogs.com/liuyang-520/p/12332443.html
Copyright © 2011-2022 走看看