Spring 的set方法(属性)注入

UserAction类中设置属性和get、set方法。(实际上只需要set方法)

private List list = null;
private Set set = null;
private Map map = null;
private Properties props = null;
//get、set方法省略。

applicationContext.xml


    
        
    
    
        
            123
            
        
    
    
        
            Hello
            12.36
            124
            true
        
    
    
        
            
                umgsai
            
            
                umgsai2
            
        
    
    
        
            as
            1265.3
        
     

MainClass.java

BeanFactory factory = new ClassPathXmlApplicationContext("applicationContext.xml");
UserAction ua = (UserAction)factory.getBean("userAction");
for(Object o : ua.getList()){
    System.out.println(o);
}
for(Object o : ua.getSet()){
    System.out.println(o);
}
for(Iterator iter = ua.getMap().entrySet.iterator();iter.hasNext();){
    Entry entry = (Entry)iter.next();
    System.out.println(entry.getKey()+":"+entry.getValue()s);
}