spring程序示例(SpringDemo项目)

时间:2014-05-12 21:29:36   收藏:0   阅读:389

Action接口:

public interface Action {

public String execute(String str);

}

Action的两个实现

public class UpperAction implements Action {

private String message;

public String getMessage() {

return message;

}

public void setMessage(String string) {

message = string;

}

public String execute(String str) {

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

}

}

 

public class LowerAction implements Action {

private String message;

public String getMessage() {

return message;

}

public void setMessage(String string) {

message = string;

}

public String execute(String str) {

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

}

}

 

配置文件bean.xml

<beans>

<description>Spring Quick Startdescription>

<bean id="TheAction"

class="com.raykey.spring.qs.UpperAction">

<property name="message">

<value>HeLLovalue>

property>

bean>

beans>

(请确保配置bean.xml位于工作路径之下,注意工作路径并不等同于CLASSPATH ,eclipse的默认工作路径为项目根路径,也就是.project文件所在的目录,而默认输出目录/bin是项目CLASSPATH的一部分,并非工作路径。)

spring程序示例(SpringDemo项目),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!