打印本文 打印本文 关闭窗口 关闭窗口
exploring spring
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3406  更新时间:2009/4/25 0:44:55  文章录入:mintao  责任编辑:mintao
     return message;

     }

     public void setMessage(String string) {

     message = string;

     }

     public String execute(String str) {

     return (getMessage() + str).toUpperCase();

     }

}

 

配置文件bean.xml

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">

<beans>

     <description>Spring Quick Start</description>

     <bean id="TheAction" class="beantest.LowerAction">

         <property name="message">

              <value>HeLLo </value>

         </property>

     </bean>

</beans>

 

使用 ApplicationContext 来操作他们

     public static void main(String[] args)

     {

         System.out.println("Hello!");

         try

         {

              ApplicationContext ctx = new FileSystemXmlApplicationContext("bean.xml");

              Action action = (Action) ctx.getBean("TheAction");

              System.out.println(action.execute("Rod Johnson"));

         }

         catch(Exception e)

         {

上一页  [1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口