Action的书写:(三种格式)
第一种:Action是一个POJO的类.
如果一个类没有实现任何接口,没有继承任何的类。这个类认为是POJO(简单的java对象).
格式:
1
2
3
4
5
6
|
public
class
ActionDemo4 {
public
String execute(){
System.out.println(
"Action Demo4..."
);
return
null
;
}
}
|
第二种:Action实现一个Action的接口.
Action的接口中提供了常用的5个逻辑视图名称:
* SUCCESS :成功.
* INPUT :数据校验.
* ERROR :错误视图
* LOGIN :登录的视图
* NONE :不跳转.
格式:
1
2
3
4
5
6
7
|
public
class
ActionDemo5
implements
Action{
@Override
public
String execute()
throws
Exception {
System.out.println(
"Action Demo5..."
);
return
null
;
}
}
|
第三种:Action类继承一个ActionSupport类:(推荐)
格式:
1
2
3
4
5
6
7
|
public
class
ActionDemo6
extends
ActionSupport{
@Override
public
String execute()
throws
Exception {
System.out.println(
"Action Demo6..."
);
return
NONE;
}
}
|