ActionSupport、Preparable_详解
来源:互联网 发布:数控铣床编程实例带图 编辑:程序博客网 时间:2024/05/18 00:58
--
- 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方法。
- Preparable接口的作用:
程序员在使用struts2的开发中,把crud方法放在某一个Action类中,就必定涉及到一些数据准备的事情;用Preparable接口就再合适不过去,只需要实现Preparable接口的prepare()方法,这个方法会在Action类的所有方法执行前被执行。
- ActionSupport、Preparable_详解
- 工作笔记:ActionSupport详解
- 详解Strut2中ActionSupport类的日志处理功能
- Struts 2的ActionSupport类的validate()方法详解
- 继承ActionSupport
- 继承ActionSupport
- actionSupport fielderror
- ActionSupport源码
- NoClassDifined --ActionSupport
- Struts2.ActionSupport
- apex:actionSupport
- 继承 actionSupport
- Struts2学习笔记(4)-ActionSupport类及Action接口详解
- struts2中的ActionSupport
- ActionSupport.getText()方法
- ActionSupport与用户验证
- Struts2(四) Validate---ActionSupport
- ActionSupport.getText()方法
- undo的图片
- iOS开发基础--Xcode以及其他的一些系统快捷键
- [MFC]系统托盘操作类,图标,气泡等
- 第八周项目4——加油
- Convnet在Windows下的使用
- ActionSupport、Preparable_详解
- Solution of Unable to start program VS C++
- HDU 4521 2013腾讯编程马拉松初赛第四场 小明系列问题——小明序列(dp思想+线段树优化)
- Cocos2d-x如何播放音乐和音效
- 【帧内预测】8.4.4.2.2 Reference sample substitution process for intra sample prediction
- native2ascii将中文国际化
- Lamda演算简介
- SYBASE常用函数
- 点击Cell插入菜单栏