标签:interface private message spring public
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
标签:interface private message spring public
原文地址:http://8917152.blog.51cto.com/8907152/1409485