Struts2中的Action类与ActionSupport类
来源:互联网 发布:死神觉醒辅助软件 编辑:程序博客网 时间:2024/05/16 11:49
一.Action类
1.Action类功能
(1)Action类在MVC模式中充当Controller角色。
(2)页面的action请求动作对应于Action,通过setter和getter负责处理和存储数据或状态,执行业务逻辑处理,将处理结果响应给用户。
2、Action类基本内容
(1)提供基本属性及属性的getter和setter方法。基本属性包括:请求参数(Form表单中标签name)和响应信息(提示信息<s:property />)。
(2)提供一个Action默认的处理方法,即public String execute(),用来执行业务逻辑的处理(调用数据库操作内容,比如hibernate或spring和hibernate整合内容),及根据处理结果的返回字符串。
(3)提供Action其他的处理方法,要求:无参;返回值类型为String,方法中处理的内容与execute()方法内容基本一致。实现时只需在配置<action>元素,指定action的method属性,这样就可以不使用execute方法处理用户请求。
3、Action类扩展
(1)Action接口
package com.opensymphony.xwork2;public interface Action(){public static final String SUCCESS="success";public static final String NONE="none";public static final String ERROR="error";public static final String INPUT="input";public static final String LOGIN="login";public String execute() throws Exeception;}
(2)ActionSupport类
Struts2框架中还提供了一个Action接口的实现类ActionSupport,该类除了实现execute()方法外,还提供了很多常用的方法,如数据处理、异常处理等。因此开发人员直接继承基类ActionSupport就可以很方便地实现业务控制器。
public class ActionSupport implements Action,ValidationAware,TextProvide,LocaleProvider,Serializable{}0 0
- Struts2中的Action类与ActionSupport类
- Struts2中的Action类与ActionSupport类
- Struts2中的Action类与ActionSupport类
- Struts2 Action接口与ActionSupport类
- Action接口与ActionSupport类
- Struts2中的Action和ActionSupport
- struts2 ActionSupport类
- struts2中的Action接口和Actionsupport接口的作用
- Struts2常用的类ActionSupport
- Struts2学习总结(三):Action与ActionSupport
- Struts2中Action和ActionSupport
- Struts2 错误 “No result defined” 与 ActionSupport 类
- struts2中的ActionSupport
- struts2中的actionSupport
- Struts2中的action类
- Struts2的数据校验(Action类必须要继承ActionSupport类)
- Struts2学习笔记(4)-ActionSupport类及Action接口详解
- Action类为何要继承ActionSupport
- ubuntu自动挂载新分区
- Win7+OpenCV2.4.9+VS2010配置
- [Object-C语言随笔1-4]
- Android kernel log 加上android logcat -v time 一样的时间戳
- iOS程序中自动滚动TableView到某行的方法
- Struts2中的Action类与ActionSupport类
- 【Struts2+Spring3+Hibernate3】SSH框架整合实现CRUD
- 记住不要把Bitmap往List等集合放
- uva2852
- OS堆栈
- 执行一个查询返回新的datatable或dataset
- POJ 3646 Dragon of Loowater
- ORACLE 11G 如何修改 awr 的保留期限小于8天
- 浅析人脸检测之Haar分类器方法