1.創(chuàng)建普通類實(shí)現(xiàn)動(dòng)作
public class Demo1action {
public String hello() {
System.err.println("執(zhí)行了hello");
return "success";
}
}
2實(shí)現(xiàn)Action接口
Action接口中的常量
SUCCESS ? "success" ?當(dāng)執(zhí)行成功后
NONE "none" 不返回任何值
ERROR "error" 當(dāng)執(zhí)行動(dòng)作方法,出現(xiàn)異常后,前往指定位置
INPUT "input" 數(shù)據(jù)回顯
LOGIN "login" 返回登錄頁(yè)面
public class Demo2action implements Action{
@Override
public String execute() throws Exception {
// TODO Auto-generated method stub
return null;
}
}
3繼承Action接口實(shí)現(xiàn)類
在類中什么都不寫,有一個(gè)默認(rèn)的動(dòng)作方法:execte()
public class Demo3action extends ActionSupport{
//在類中什么都不寫,有一個(gè)默認(rèn)的動(dòng)作方法:execte()
}