• Spring 注入集合


    Spring 中,注入集合类型的数值方式

        <bean id="javaCollection" class="com.qie_zi.JavaCollection">
            <property name="addressList">
                <list>
                    <value>1</value>
                    <value>2</value>
                    <value>3</value>
                    <value>4</value>
                </list>
            </property>
            
            <property name="addressMap">
                <map>
                    <entry key="1" value="1"></entry>        
                    <entry key="2" value="2"></entry>        
                    <entry key="3" value="3"></entry>        
                    <entry key="4" value="4"></entry>        
                </map>
            </property>
            
            <property name="addressSet">
                <set>
                    <value>1</value>
                    <value>2</value>
                    <value>3</value>
                    <value>4</value>
                </set>
            </property>
            
            <property name="addressProp">
                <props>
                    <prop key="1">1</prop>
                    <prop key="1">2</prop>
                    <prop key="1">3</prop>
                    <prop key="1">4</prop>
                </props>
            </property>
        </bean>

    list  

            <property name="addressList">
                <list>
                    <value>1</value>
                    <value>2</value>
                    <value>3</value>
                    <value>4</value>
                </list>
            </property>

    map

            <property name="addressMap">
                <map>
                    <entry key="1" value="1"></entry>        
                    <entry key="2" value="2"></entry>        
                    <entry key="3" value="3"></entry>        
                    <entry key="4" value="4"></entry>        
                </map>
            </property>

    set

            <property name="addressSet">
                <set>
                    <value>1</value>
                    <value>2</value>
                    <value>3</value>
                    <value>4</value>
                </set>
            </property>

    Properties

            <property name="addressProp">
                <props>
                    <prop key="1">1</prop>
                    <prop key="1">2</prop>
                    <prop key="1">3</prop>
                    <prop key="1">4</prop>
                </props>
            </property>

     附录:pojo

    package com.qie_zi;
    
    import java.util.List;
    import java.util.Map;
    import java.util.Properties;
    import java.util.Set;
    
    public class JavaCollection {
        Map addressMap;
        List addressList;
        Set addressSet;
        Properties addressProp;
    
        public Map getAddressMap() {
            return addressMap;
        }
    
        public void setAddressMap(Map addressMap) {
            this.addressMap = addressMap;
        }
    
        public List getAddressList() {
            return addressList;
        }
    
        public void setAddressList(List addressList) {
            this.addressList = addressList;
        }
    
        public Set getAddressSet() {
            return addressSet;
        }
    
        public void setAddressSet(Set addressSet) {
            this.addressSet = addressSet;
        }
    
        public Properties getAddressProp() {
            return addressProp;
        }
    
        public void setAddressProp(Properties addressProp) {
            this.addressProp = addressProp;
        }
    
    }
  • 相关阅读:
    个人觉得在前台比较通用的校验的提示方法
    平时面试总结
    sturts2批量导入excel中的信息入库大致代码
    在B/S系统中得到spring的ApplicationContext对象的一点小技巧
    Oracle同义词创建及其作用
    Oracle中创建dblink的方法
    真实项目中struts2 导出excel文件
    十二款jQuery插件(编辑器,图片,验证等)
    华丽到暴表的网站 cnn ecosphere
    Mysql 临时表
  • 原文地址:https://www.cnblogs.com/qie-zi/p/8854268.html
Copyright © 2020-2023  润新知