Struts2 三种action类

来源:互联网 发布:bbs url 网络推广 编辑:程序博客网 时间:2024/04/25 04:55

普通类Action
调用方便,可融合性高
public class PojoAction {
public String execute() throws Exception{
return “success”;
}
}

继承Action类Action
返回宏 进行方法覆盖,相对于第一种更加不容易出错
public class ActionAction implements Action {
@Override
public String execute() throws Exception {
return SUCCESS;
}
}

最推荐第三种
继承ActionSupport,提供验证方法
最标准
public class ActionSuportAction extends ActionSupport {
@Override
public void validate() {
super.validate();
}

@Overridepublic String execute() throws Exception {    return super.execute();}

}

0 0