Struts2原始碼分析討論

2021-08-22 12:57:35 字數 836 閱讀 7242

最近一直在研究struts2,看了李剛寫的一本struts2權威指南,但感覺講的還是有點淺,但是做為入門的話,還是不錯的.現在開始看struts2的原始碼,但由於本人能力有限,看的是頭暈腦漲的,有很多不明白的地方,所以想把不明白的地方貼出來跟大家一起討論討論.

其中有一處也覺的是比較關鍵的一步:

以下是defaultactioninvocation中的invoke()方法的原始碼:

[code]

public string invoke() throws exception

if (interceptors.hasnext())

});} else

// this is needed because the result will be executed, then control will return to the interceptor, which will

// return above and flow through again

if (!executed)

finally }}

// now execute the result, if we're supposed to

if (proxy.getexecuteresult())

executed = true;

}return resultcode;

}finally

}[/code]

不明白是怎樣迭代執行乙個又乙個的interceptor中的intercept方法.

按照我的理解,至少我可以看到乙個迴圈遍厲interceptors這個集合才對.

大家可以討論討論,有知道的也可以告訴我.謝謝.

struts2原始碼執行流程

先進入核心過濾器,然後判斷該請求是不是由struts2執行的,是的話 1 建立actioncontext 其中其實先建立乙個valuestack,然後從其中拿出context用來建立actioncontext 2 把request包裝成乙個新的request 包裝了getattribute方法,包裝...

Struts2請求處理流程及原始碼分析

1.乙個請求在struts2框架中的處理步驟 a 客戶端初始化乙個指向servlet容器的請求 b 根據web.xml配置,請求首先經過actioncontextcleanup過濾器,其為可選過濾器,這個過濾器對於struts2和其他框架的整合 很有幫助 sitemesh plugin 主要清理當前...

Struts2請求處理流程及原始碼分析

原文出處 1.1 struts2請求處理 1.乙個請求在struts2框架中的處理步驟 a 客戶端初始化乙個指向servlet容器的請求 b 根據web.xml配置,請求首先經過actioncontextcleanup過濾器,其為可選過濾器,這個過濾器對於struts2和其他框架的整合很有幫助 si...