struts 中继承ActionSupport类
来源:互联网 发布:go和java 编辑:程序博客网 时间:2024/04/29 16:29
理论上Struts 2.0的Action无须实现任何接口或继承任何类型,但是,我们为了方便实现Action,大多数情况下都会继承com.opensymphony.xwork2.ActionSupport类,并重载(Override)此类里的String execute()方法。
由JavaDoc可知,ActionSupport类实现了接口。
com.opensymphony.xwork2.Action。
com.opensymphony.xwork2.LoaleProvider。
com.opensymphony.xwork2.TextProvider。
com.opensymphony.xwork2.Validateable。
com.opensymphony.xwork2.ValidationAware。
com.uwyn.rife.continuations.ContinuableObject。
java.io.Searializable。
java.lang.Cloneable。
例如下例所示:
public class HelloWorld extends ActionSupport {
private String message;
public String getMessage() { return message; } public String execute() { message = " Hello World, Now is " + DateFormat.getInstance().format( new Date()); return SUCCESS; }
}
然后可以配置如下映射:
/HelloWorld.jsp
在默认情况下,当请求HelloWorld.do发生时,Struts 2会根据struts.xml里的Action映射集(Mapping)实例化tutoiral.HelloWorld类,并调用其execute()方法。当然,我们可以通过以下两种方法改变这种默认调用,这个功能(Feature)有点类似Struts 1中的LookupDispathAction。
在sturts.xml中新建Action,并指明其调用的方法。
访问Action时,在Action名后加上”!xxx”(xxx为方法名)。
例如我们可以在tutorial/HelloWorld.java中加入以下方法:
public String aliasAction() {
message =”自定义Action调用方法”;
return SUCCESS;
}
然后可以在sturts.xml中指定method来设置请求的函数名:
- struts 中继承ActionSupport类
- struts 中继承ActionSupport类
- struts 中继承ActionSupport类
- struts 中继承ActionSupport类 HelloWorld!aliasAction.action
- struts2中继承ActionSupport类的作用
- Struts 的 ActionSupport 类
- struts中 Actionsupport 的作用
- Struts2 中继承ActionSupport类,都需要jar包
- 继承ActionSupport
- 继承ActionSupport
- 继承 actionSupport
- Action类为何要继承ActionSupport
- Action类为何要继承ActionSupport
- struts中的ActionSupport基类
- Struts之ActionSupport
- 为什么要继承ActionSupport
- Struts2继承ActionSupport接口
- Struts 2的ActionSupport类的validate()方法详解
- Linux下printf函数显示不同的颜色 !!!!
- 日本除了AV,还有什么? 看完彻底震惊了!
- HttpConnect与HttpClient基本用法
- const在c与c++
- R语言-入门综合
- struts 中继承ActionSupport类
- Civ6
- Android快速开发最常用的工具类集锦--好东西在精不在多
- Android内存泄露案例和解析
- ssh
- Android第一行代码源码分享
- CodeForces 667APouring Rain
- Nginx和Apache比较
- Linux下python版本的更新以及第三方包的安装