Strut2流程分析-----从请求到Action方法()
2014-09-24 15:34
127 查看
手写请求会通过strutsPrepareAndExcuteFliter的doFilter()方法
然后会调用StrutsActionProxy类的excute()方法,生成一个代理类(ActionProxy)
ActionProxy 是 Action 的一个代理类,也就是说Action的调用是通过 ActionProxy 实现的,
而该方法又调用了ActionInvocation.invoke()方法
然后调用DefaultActionInvocation的invoke()//通过不断的回调这个方法,调用了所有拦截器
ActionInvocation就是Action的调用者。
ActionInvocation在Action的执行过程中,负责Interceptor、Action和Result等一系列元素的调度。
*/
public String invoke() throws Exception {
String profileKey = "invoke: ";
try {
UtilTimerStack.push(profileKey);
if (executed) {
throw new IllegalStateException("Action has already executed");
}
if (interceptors.hasNext()) {//拦截器集合,不断的回调,
final InterceptorMapping interceptor = interceptors.next();
String interceptorMsg = "interceptor: " + interceptor.getName();
UtilTimerStack.push(interceptorMsg);
try {
resultCode = interceptor.getInterceptor().intercept(DefaultActionInvocation.this);
}
finally {
UtilTimerStack.pop(interceptorMsg);//拦截器回调完后,最终通过这个方法来调用Action类方法
}
} else {
resultCode = invokeActionOnly();
}
然后会调用StrutsActionProxy类的excute()方法,生成一个代理类(ActionProxy)
ActionProxy 是 Action 的一个代理类,也就是说Action的调用是通过 ActionProxy 实现的,
而该方法又调用了ActionInvocation.invoke()方法
然后调用DefaultActionInvocation的invoke()//通过不断的回调这个方法,调用了所有拦截器
ActionInvocation就是Action的调用者。
ActionInvocation在Action的执行过程中,负责Interceptor、Action和Result等一系列元素的调度。
*/
public String invoke() throws Exception {
String profileKey = "invoke: ";
try {
UtilTimerStack.push(profileKey);
if (executed) {
throw new IllegalStateException("Action has already executed");
}
if (interceptors.hasNext()) {//拦截器集合,不断的回调,
final InterceptorMapping interceptor = interceptors.next();
String interceptorMsg = "interceptor: " + interceptor.getName();
UtilTimerStack.push(interceptorMsg);
try {
resultCode = interceptor.getInterceptor().intercept(DefaultActionInvocation.this);
}
finally {
UtilTimerStack.pop(interceptorMsg);//拦截器回调完后,最终通过这个方法来调用Action类方法
}
} else {
resultCode = invokeActionOnly();
}
相关文章推荐
- Action请求流程分析
- Spring MVC 教程,快速入门,深入分析――请求如何映射到具体的Action中的方法?
- HTTP协议中请求方法分析
- 一个Action内包含多个请求处理方法的处理
- Struts2中一个Action多个请求处理方法的三种实现方式
- Android中View绘制流程以及invalidate()等相关方法分析
- Struts2 的Action中取得请求参数值的几种方法
- struts为每个独立请求创建一个Action的方法
- Android中View绘制流程以及invalidate()等相关方法分析
- 在Struts2的Action中取得请求参数值的几种方法
- 在Struts2的Action中取得请求参数值的几种方法
- Android中View绘制流程以及invalidate()等相关方法分析
- 一个Action内包含多个请求处理方法的处理
- 减少图片HTTP请求的方法分析
- win2003 iis 不支持请求(iis iso)的解决方法分析
- struts2架构及请求流程分析
- Rails源代码分析(40):ActionController Base的render方法
- Yii请求处理流程分析
- Zend framework处理一个http请求的流程分析
- Struts2一个Action内包含多个请求处理方法的处理,method的使用方法,struts2中的路径问题,通配符映射