struts2的ActionProxy
2016-06-30 10:48
567 查看
ctinoProxy的全名是com.opensymphony.xwork2.ActionProxy,
ActionProxy = Action + Proxy,从字面意思来解释:Action的代理。
在Struts中,ActionContext、ActionInvocation、ActionProxy、ActionConfig联系的很紧密。
(1.1)从ActionContext对象可以得到ActionInvocation对象
(1.2)从ActionInvocation对象可以得到ActionContext对象
(2.1)从ActionInvocation对象可以得到ActionProxy对象
(2.2)从ActionProxy对象可以得到ActionInvocation对象
(3.1)从ActionProxy对象可以得到ActionConfig对象
在搜索的时候 ,遇到一句描述ActionInvocation和ActionProxy关系的话,感觉非常切中要害:
Essentially, ActionProxy encapsulates how an Action can be obtained. ActionInvocation encapsulates how the Action is executed when a request is invoked.
本质上来,ActionProxy对如何获取Action对象进行了封装,而ActionInvocation对如何执行Action进行了封装。
原话地址:https://struts.apache.org/docs/action-proxy-actionproxy-factory.html
Typically, an ActionProxy will utilize the ActionInvocation to encapsulate the execution of a particular request.
The ActionInvocation determines how an Action is handled: Is it being intercepted? Is there a PreResultListener acting on it?
![](http://s4.51cto.com/wyfs02/M02/83/76/wKioL1dz40yDz_qjAABmO-FTeq4881.png)
在上面图中,
ActionConfig,负责从struts.xml文件中读取配置;
ActionSupport,我们自己实现的Action类一般都继承ActionSupport类;
ActionContext,是Action运行的环境,为Action类提供一些信息;
ActionProxy,是如何获取Action;
ActionInvocation是如何执行Action。
上面标的(1)至(4),都能通过ActionProxy来获得:
(1)表示当前Action类在struts.xml文件中对应的<action>标签所在的<package>标签的namespace属性
(2)表示<action>标签的name属性
(3)表示真实的Action类的实例,不是字符串类型,而<action>标签的class属性对应的类的实例化。
(4)<action>标签的method属性
从一些java培训机构的视频来看,ActionProxy实现了URL和真正Action类之间的映射。
1、如何获取ActionProxy对象
2、如何获取ActionProxy中的值
(1)获取当前<action>所在的命名空间
(2)获取<action>的名字
(3)获取Action类的实例
(4)获取<action>执行的方法
(5)得到ActionInvocation和ActionConfig对象
3、ActionProxy的源代码
ActionProxy = Action + Proxy,从字面意思来解释:Action的代理。
在Struts中,ActionContext、ActionInvocation、ActionProxy、ActionConfig联系的很紧密。
(1.2)从ActionInvocation对象可以得到ActionContext对象
(2.1)从ActionInvocation对象可以得到ActionProxy对象
(2.2)从ActionProxy对象可以得到ActionInvocation对象
(3.1)从ActionProxy对象可以得到ActionConfig对象
在搜索的时候 ,遇到一句描述ActionInvocation和ActionProxy关系的话,感觉非常切中要害:
Essentially, ActionProxy encapsulates how an Action can be obtained. ActionInvocation encapsulates how the Action is executed when a request is invoked.
本质上来,ActionProxy对如何获取Action对象进行了封装,而ActionInvocation对如何执行Action进行了封装。
原话地址:https://struts.apache.org/docs/action-proxy-actionproxy-factory.html
Typically, an ActionProxy will utilize the ActionInvocation to encapsulate the execution of a particular request.
The ActionInvocation determines how an Action is handled: Is it being intercepted? Is there a PreResultListener acting on it?
![](http://s4.51cto.com/wyfs02/M02/83/76/wKioL1dz40yDz_qjAABmO-FTeq4881.png)
在上面图中,
ActionConfig,负责从struts.xml文件中读取配置;
ActionSupport,我们自己实现的Action类一般都继承ActionSupport类;
ActionContext,是Action运行的环境,为Action类提供一些信息;
ActionProxy,是如何获取Action;
ActionInvocation是如何执行Action。
上面标的(1)至(4),都能通过ActionProxy来获得:
(1)表示当前Action类在struts.xml文件中对应的<action>标签所在的<package>标签的namespace属性
(2)表示<action>标签的name属性
(3)表示真实的Action类的实例,不是字符串类型,而<action>标签的class属性对应的类的实例化。
(4)<action>标签的method属性
从一些java培训机构的视频来看,ActionProxy实现了URL和真正Action类之间的映射。
1、如何获取ActionProxy对象
(1)获取当前<action>所在的命名空间
相关文章推荐
- Java中5种方式实现String反转
- (一)Spring4.0初步认识
- Eclipse 安装Web Service、Axis2插件
- struts自定义验证规则
- spring使用模板发送邮件
- 深入理解Java:注解(Annotation)--注解处理器
- 使用JDK开发WebService
- 华为机试---二维数组打印
- 基于SpringAop 的统一验证
- Spring 定时任务
- 深入理解Java:注解(Annotation)基本概念
- JAVA volatile关键字解析
- token
- java中的代码块
- java 计算String的ASCII码
- 各种 Java Thread State 第一分析法则
- 深入理解Java:注解(Annotation)自定义注解入门
- Java实现KMP算法
- Reason: Failed while changing version of java to 1.7
- 二叉树的非递归遍历的解析与实现----java实现