Action类的扩展

来源:互联网 发布:pscc2017 mac版本下载 编辑:程序博客网 时间:2024/06/08 19:04

1、ModelDriven接口

将请求参数看做模型即对象,并返回给Action类

 

2、Action接口

提供execute()方法,以及常量如:SUCCESS,ERROR

 

3、ActionSupport类

它是一个工具类,它已经实现了Action接口和Validateable接口,提供可数据校验功能。在Validateable接口中定义了一个validate()方法。

 

4、Preparable接口

使用场景:如果action针对每次请求都要执行一些相同的业务逻辑,那么可以实现Preparable接口,将预处理业务逻辑写在prepare()方法里。

 

5、ServletActionContext类调用servlet API

案例:ServletActionContext.getRequest().getSession().setAttribute("goods","苹果");