登陆 | 注册
你现在的位置:我的论坛 >> java >> hello spring
hello spring
大狗熊

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
    
<bean id="summer_hello" class="summer.Hello">    
        
<property name="hello">
            
<value>Hello World</value>
        
</property>
    
</bean>
</beans>

  package summer;
public class Hello
{
    
private String hello;

    
public String getHello()
    
{
        
return hello;
    }


    
public void setHello(String hello)
    
{
        
this.hello = hello;
    }

}


package summer;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;

public class Main
{

    
public static void main(String[] args)
    
{
        ApplicationContext ctx 
= new FileSystemXmlApplicationContext("src/summer.xml");
        Hello h
=(Hello)ctx.getBean("summer_hello");
        System.out.print(h.getHello());
    }


}

楼主 创建:08-06-15 12:11:55 更新:08-06-15 12:11:55
发表回复


Copyright (C) 2004-2008, All Rights Reserved