首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

一些spring的小疑点,处理中/。再现等,

2012-02-10 
一些spring的小问题,处理中/。。。。。。再现等,急!!!publicinterfaceAction{publicStringexecute(Stringstr)}p

一些spring的小问题,处理中/。。。。。。再现等,急!!!
public   interface   Action   {
public   String   execute(String   str);
}

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   void   testQuickStart()   {
ApplicationContext   ctx=new
FileSystemXmlApplicationContext( "bean.xml ");
Action   action   =   (Action)   ctx.getBean( "TheAction ");
System.out.println(action.execute( "Rod   Johnson "));
}


问题   1.     (getMessage()   +   str).toUpperCase();是什么意思,为什么不直接(string   +   str).toUpperCase();,       toUpperCase()这个函数哪里来的?好像没定义过

问题2.       Action   action   =   (Action)   ctx.getBean( "TheAction ");这句话什么意思,特别是   (Action)   ctx.getBean( "TheAction ");   这个写法,不太看得懂

问题3.     Action这种接口   ,在jdk的api文件里查不到execute这种方法
,还有jdk的api中有没有servlet?


再现等,急!!!

[解决办法]
1. (getMessage() + str).toUpperCase();是指将message和str的值连接起来再变为大写字符。
toUpperCase()是在String对象中定义的。

2. Action action = (Action) ctx.getBean( "TheAction ");是指取得在bean.xml中定义的“TheAction”bean的对象。

3. Action接口是你上面代码中定义的,与jdk和servlet无关。

热点排行