struts2 中 Actionsupport 的作用
来源:互联网 发布:黑马程序员官网登录 编辑:程序博客网 时间:2024/05/30 23:35
struts2 中 Actionsupport 的作用
Action 跟 Actionsupport 的区别
当我们在写action的时候,可以实现Action接口,也可以继承Actionsupport这个类.到底这两个有什么区别呢?
Action接口有:
public static final java.lang.String SUCCESS = "success";
public static final java.lang.String NONE = "none";
public static final java.lang.String ERROR = "error";
public static final java.lang.String INPUT = "input";
public static final java.lang.String LOGIN = "login";
public abstract java.lang.String execute() throws java.lang.Exception;
而Actionsupport这个工具类在实现了Action接口的基础上还定义了一个validate()方法,重写该方法,它会在execute()方法之前执行,如校验失败,会转入input处,必须在配置该Action时配置input属性。
另外,Actionsupport还提供了一个getText(String key)方法还实现国际化,该方法从资源文件上获取国际化信息.
这样在自定义标签时可以定义一个变量为new actionsupport对象实现国际化。
ActionSupport类的作用
struts2不要求我们自己设计的action类继承任何的struts基类或struts接口,但是我们为了方便实现我们自己的action,大多数情况下都会继承com.opensymphony.xwork2.ActionSupport类,并重写此类里的public String execute() throws Exception方法。因为此类中实现了很多的实用借口,提供了很多默认方法,这些默认方法包括国际化信息的方法、默认的处理用户请求的方法等,这样可以大大的简化Acion的开发。
Struts2中通常直接使用Action来封装HTTP请求参数,因此,Action类里还应该包含与请求参数对应的属性,并且为属性提供对应的getter和setter方法。
Action 跟 Actionsupport 的区别
当我们在写action的时候,可以实现Action接口,也可以继承Actionsupport这个类.到底这两个有什么区别呢?
Action接口有:
public static final java.lang.String SUCCESS = "success";
public static final java.lang.String NONE = "none";
public static final java.lang.String ERROR = "error";
public static final java.lang.String INPUT = "input";
public static final java.lang.String LOGIN = "login";
public abstract java.lang.String execute() throws java.lang.Exception;
而Actionsupport这个工具类在实现了Action接口的基础上还定义了一个validate()方法,重写该方法,它会在execute()方法之前执行,如校验失败,会转入input处,必须在配置该Action时配置input属性。
另外,Actionsupport还提供了一个getText(String key)方法还实现国际化,该方法从资源文件上获取国际化信息.
这样在自定义标签时可以定义一个变量为new actionsupport对象实现国际化。
ActionSupport类的作用
struts2不要求我们自己设计的action类继承任何的struts基类或struts接口,但是我们为了方便实现我们自己的action,大多数情况下都会继承com.opensymphony.xwork2.ActionSupport类,并重写此类里的public String execute() throws Exception方法。因为此类中实现了很多的实用借口,提供了很多默认方法,这些默认方法包括国际化信息的方法、默认的处理用户请求的方法等,这样可以大大的简化Acion的开发。
Struts2中通常直接使用Action来封装HTTP请求参数,因此,Action类里还应该包含与请求参数对应的属性,并且为属性提供对应的getter和setter方法。
0 0
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2中actionsupport的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- struts2 中 Actionsupport 的作用
- 【JAVA学习】struts2 中 Actionsupport 的作用
- 关于Struts2中ActionSupport的作用
- struts2中继承ActionSupport类的作用
- struts中 Actionsupport 的作用
- struts2 中 action 跟 actionsupport 的区别
- struts2中ActionSupport校验
- struts2中的Action接口和Actionsupport接口的作用
- 第三方开源库:EditText相关:GridPasswordView
- C#学习之System.Environment类
- 外网IP内网IP的区别
- 关于树形菜单的创建
- 用matlab分水岭算法做海岸线的提取
- struts2 中 Actionsupport 的作用
- petalinux如何用SD卡上的设备树
- 柠檬酱:苹果偏爱的二人组和其成长的烦恼
- 【JAVA SE】8.方法
- UITextField实时跟踪输入文字的个数,超过禁止输入并阶段(UITextView也可以使用类似方法)
- Java没有sizeof
- spring mvc controller间跳转 重定向 传参
- 《机器学习》——附录
- 机器学习系列:(五)决策树——非线性回归与分类