请问com.opensymphony.xwork2.Action;  和com.opensymphony.xwork2.ActionSupport;有什么区别嘛 ?  我在各例子里看到public class AdminAction extends ActionSupport implements Action {//省略一万行代码
}  
如果只继承 ActionSupport  行不行?

解决方案 »

  1.   

    Action是一个接口
    ActionSupport是实现了Action接口 struts2不要求我们自己设计的action类继承任何的struts基类或struts接口,但是我们为了方便实现我们自己的action,大多数情况下都会继承com.opensymphony.xwork2.ActionSupport类,并重写此类里的public String execute() throws Exception方法。因为此类中实现了很多的实用借口,提供了很多默认方法,这些默认方法包括国际化信息的方法、默认的处理用户请求的方法等,这样可以大大的简化Acion的开发。 
      

  2.   

    public class ActionSupport extends Object implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, Serializable楼主有没有仔细了解过源码。
      

  3.   

    如果只继承是可以的。而且大多数都是写继承SupportAction不写implements Action