zoukankan      html  css  js  c++  java
  • Strut2流程分析-----从请求到Action方法()


    手写请求会通过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();
    }

  • 相关阅读:
    斐波那契数列——兔子问题
    最长上升子序列
    洛谷P1325 雷达安装
    K短路
    DIJ的优化,和spfa的优化
    洛谷P5017摆渡车
    洛谷P2258 子矩阵
    三元表达式、列表推导式和生成器表达式
    递归调用、 二分法
    匿名函数、内置函数
  • 原文地址:https://www.cnblogs.com/jeremy-blog/p/3990854.html
Copyright © 2011-2022 走看看