2011년 11월 12일 토요일

SpringFramework Injection di property

User.java   method
package com.domain;

public class User {
   
// name , age , country 에 beans.xml 에서 bean property 를 이용하여 값을 설정 할수있다
    private String name;
    private int    age;
    private String country;
   
   
   
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
    public String getCountry() {
        return country;
    }
    public void setCountry(String country) {
        this.country = country;
    }
   

    public String toString (){
        return "Name : " + name + " : " + age + " : " + country;
    }
   
}




beans.xml

  <bean id="user" class="com.domain.User">
       <property name="name"    value="홍길동"></property>
       <property name="age"     value="20"></property>
       <property name="country" value="조선"></property>
   </bean>

댓글 없음:

댓글 쓰기