锘??xml version="1.0" encoding="utf-8" standalone="yes"?>国产亚洲精品观看91在线,亚洲精品夜夜夜妓女网,亚洲午夜精品一级在线播放放 http://www.tkk7.com/hellxoul/category/50246.htmlzh-cnFri, 14 Dec 2012 07:45:47 GMTFri, 14 Dec 2012 07:45:47 GMT60Struts2涓殑鎷︽埅鍣?/title><link>http://www.tkk7.com/hellxoul/archive/2012/12/14/392970.html</link><dc:creator>hellxoul</dc:creator><author>hellxoul</author><pubDate>Fri, 14 Dec 2012 02:41:00 GMT</pubDate><guid>http://www.tkk7.com/hellxoul/archive/2012/12/14/392970.html</guid><wfw:comment>http://www.tkk7.com/hellxoul/comments/392970.html</wfw:comment><comments>http://www.tkk7.com/hellxoul/archive/2012/12/14/392970.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.tkk7.com/hellxoul/comments/commentRss/392970.html</wfw:commentRss><trackback:ping>http://www.tkk7.com/hellxoul/services/trackbacks/392970.html</trackback:ping><description><![CDATA[<div>鎺ヤ笅鏉ワ紝鎴戜滑灝嗛噸鐐硅璁轟竴涓婼truts2涓殑鎷︽埅鍣ㄧ殑鍐呴儴緇撴瀯鍜屾墽琛岄『搴忥紝騫剁粨鍚堟簮鐮佽繘琛屽垎鏋愩? <div class="xr77ptn" id="wiki_menu"> <h4>鐩?褰?<a title="闅愯棌/鏄劇ず鐩綍"><small>[ - ]</small></a></h4> <ol><li><a >Interceptor緇撴瀯</a></li><li><a >Interceptor鎵ц鍒嗘瀽</a></li><li><a >婧愮爜瑙f瀽</a></li></ol> </div> <h2> Interceptor緇撴瀯 <a name="1678" ><img alt="Top" src="http://www.iteye.com/images/wiki/top.gif?1324994303" /></a> </h2> <div> 璁╂垜浠啀鏉ュ洖欏句竴涓嬩箣鍓嶆垜浠浘緇忕敤榪囩殑涓寮燗ction LifeCycle鐨勫浘錛?<br /> <br /><img src="http://www.iteye.com/upload/attachment/68182/ae963ed3-fae7-3710-bfcf-2fc49942ee90.png" alt="" /> <br /> <br />鍥句腑錛屾垜浠彲浠ュ彂鐜幫紝Struts2鐨処nterceptor涓灞備竴灞傦紝鎶夾ction鍖呰9鍦ㄦ渶閲岄潰銆傝繖鏍風殑緇撴瀯錛屽ぇ姒傛湁浠ヤ笅涓浜涚壒鐐癸細 <br /> <br /><strong>1. 鏁翠釜緇撴瀯灝卞鍚屼竴涓爢鏍堬紝闄や簡Action浠ュ錛屽爢鏍堜腑鐨勫叾浠栧厓绱犳槸Interceptor</strong> <br /> <br /><strong>2. Action浣嶄簬鍫嗘爤鐨勫簳閮ㄣ傜敱浜庡爢鏍?鍏堣繘鍚庡嚭"鐨勭壒鎬э紝濡傛灉鎴戜滑璇曞浘鎶夾ction鎷垮嚭鏉ユ墽琛岋紝鎴戜滑蹇呴』棣栧厛鎶婁綅浜嶢ction涓婄鐨処nterceptor鎷垮嚭鏉ユ墽琛屻傝繖鏍鳳紝鏁翠釜鎵ц灝卞艦鎴愪簡涓涓掑綊璋冪敤</strong> <br /> <br /><strong>3. 姣忎釜浣嶄簬鍫嗘爤涓殑Interceptor錛岄櫎浜嗛渶瑕佸畬鎴愬畠鑷韓鐨勯昏緫錛岃繕闇瑕佸畬鎴愪竴涓壒孌婄殑鎵ц鑱岃矗銆傝繖涓墽琛岃亴璐f湁3縐嶉夋嫨錛?<br /> <br /><span style="color: blue;">1) 涓鏁翠釜鎵ц錛岀洿鎺ヨ繑鍥炰竴涓瓧絎︿覆浣滀負resultCode</span> <br /> <br /><span style="color: blue;">2) 閫氳繃閫掑綊璋冪敤璐熻矗璋冪敤鍫嗘爤涓笅涓涓狪nterceptor鐨勬墽琛?/span> <br /> <br /><span style="color: blue;">3) 濡傛灉鍦ㄥ爢鏍堝唴宸茬粡涓嶅瓨鍦ㄤ換浣曠殑Interceptor錛岃皟鐢ˋction</span> <br /></strong> <br /> <br />Struts2鐨勬嫤鎴櫒緇撴瀯鐨勮璁★紝瀹為檯涓婃槸涓涓吀鍨嬬殑<strong>璐d換閾炬ā寮?/strong>鐨勫簲鐢ㄣ傞鍏堝皢鏁翠釜鎵ц鍒掑垎鎴愯嫢騫茬浉鍚岀被鍨嬬殑鍏冪礌錛屾瘡涓厓绱犲叿澶囦笉鍚岀殑閫昏緫璐d換錛屽茍灝嗕粬浠撼鍏ュ埌涓涓摼寮忕殑鏁版嵁緇撴瀯涓紙鎴戜滑鍙互鎶婂爢鏍堢粨鏋勪篃鐪嬩綔鏄竴涓掑綊鐨勯摼寮忕粨鏋勶級錛岃屾瘡涓厓绱犲張鏈夎矗浠昏礋璐i摼寮忕粨鏋勪腑涓嬩竴涓厓绱犵殑鎵ц璋冪敤銆?<br /> <br />榪欐牱鐨勮璁★紝浠庝唬鐮侀噸鏋勭殑瑙掑害鏉ョ湅錛屽疄闄呬笂鏄皢涓涓鏉傜殑緋葷粺錛屽垎鑰屾不涔嬶紝浠庤屼嬌寰楁瘡涓儴鍒嗙殑閫昏緫鑳藉楂樺害閲嶇敤騫跺叿澶囬珮搴﹀彲鎵╁睍鎬с傛墍浠ワ紝Interceptor緇撴瀯瀹炲湪鏄疭truts2/Xwork璁捐涓殑綺懼崕涔嬬瑪銆? </div> <h2> Interceptor鎵ц鍒嗘瀽 <a name="1679" ><img alt="Top" src="http://www.iteye.com/images/wiki/top.gif?1324994303" /></a> </h2> <div> <strong><span style="color: blue;">Interceptor鐨勫畾涔?/span></strong> <br /> <br />鎴戜滑鏉ョ湅涓涓婭nterceptor鐨勬帴鍙g殑瀹氫箟錛?<br /> <br /><div class="7hv9p9z" id=""><div><div>Java浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span>public interface Interceptor extends Serializable {  </span></li><li>  </li><li>    <span>/** </span></li><li><span>     * Called to let an interceptor clean up any resources it has allocated. </span></li><li><span>     */  </span></li><li>    <span>void destroy();  </span></li><li>  </li><li>    <span>/** </span></li><li><span>     * Called after an interceptor is created, but before any requests are processed using </span></li><li><span>     * {@link #intercept(com.opensymphony.xwork2.ActionInvocation) intercept} , giving </span></li><li><span>     * the Interceptor a chance to initialize any needed resources. </span></li><li><span>     */  </span></li><li>    <span>void init();  </span></li><li>  </li><li>    <span>/** </span></li><li><span>     * Allows the Interceptor to do some processing on the request before and/or after the rest of the processing of the </span></li><li><span>     * request by the {@link ActionInvocation} or to short-circuit the processing and just return a String return code. </span></li><li><span>     * </span></li><li><span>     * @return the return code, either returned from {@link ActionInvocation#invoke()}, or from the interceptor itself. </span></li><li><span>     * @throws Exception any system-level error, as defined in {@link com.opensymphony.xwork2.Action#execute()}. </span></li><li><span>     */  </span></li><li>    String intercept(ActionInvocation invocation) <span>throws Exception;  </span></li><li>}  </li></ol></div> <br /> <br />Interceptor鐨勬帴鍙e畾涔夋病鏈変粈涔堢壒鍒殑鍦版柟錛岄櫎浜唅nit鍜宒estory鏂規(guī)硶浠ュ錛宨ntercept鏂規(guī)硶鏄疄鐜版暣涓嫤鎴櫒鏈哄埗鐨勬牳蹇冩柟娉曘傝屽畠鎵渚濊禆鐨勫弬鏁癆ctionInvocation鍒欐槸鎴戜滑涔嬪墠绔犺妭涓浘緇忔彁鍒拌繃鐨勮憲鍚嶇殑<strong>Action璋冨害鑰?/strong>銆?<br /> <br />鎴戜滑鍐嶆潵鐪嬬湅涓涓吀鍨嬬殑Interceptor鐨勬娊璞″疄鐜扮被錛?<br /> <br /><div class="h9hpf99" id=""><div><div>Java浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span>public abstract class AroundInterceptor extends AbstractInterceptor {  </span></li><li>      </li><li>    <span>/* (non-Javadoc) </span></li><li><span>     * @see com.opensymphony.xwork2.interceptor.AbstractInterceptor#intercept(com.opensymphony.xwork2.ActionInvocation) </span></li><li><span>     */  </span></li><li>    <span>@Override  </span></li><li>    <span>public String intercept(ActionInvocation invocation) throws Exception {  </span></li><li>        String result = <span>null;  </span></li><li>  </li><li>        before(invocation);  </li><li>        <span>// 璋冪敤涓嬩竴涓嫤鎴櫒錛屽鏋滄嫤鎴櫒涓嶅瓨鍦紝鍒欐墽琛孉ction  </span></li><li>        result = invocation.invoke();  </li><li>        after(invocation, result);  </li><li>  </li><li>        <span>return result;  </span></li><li>    }  </li><li>      </li><li>    <span>public abstract void before(ActionInvocation invocation) throws Exception;  </span></li><li>  </li><li>    <span>public abstract void after(ActionInvocation invocation, String resultCode) throws Exception;  </span></li><li>  </li><li>}  </li></ol></div> <br /> <br />鍦ㄨ繖涓疄鐜扮被涓紝瀹為檯涓婂凡緇忓疄鐜頒簡鏈綆鍗曠殑鎷︽埅鍣ㄧ殑闆忓艦銆傛垨璁稿ぇ瀹跺榪欐牱鐨勪唬鐮佽繕姣旇緝闄岀敓錛岃繖娌℃湁鍏崇郴銆傛垜鍦ㄨ繖閲岄渶瑕佹寚鍑虹殑鏄竴涓緢閲嶈鐨勬柟娉?invocation.invoke()銆傝繖鏄疉ctionInvocation涓殑鏂規(guī)硶錛岃孉ctionInvocation鏄疉ction璋冨害鑰咃紝鎵 浠ヨ繖涓柟娉曞叿澶囦互涓?灞傚惈涔夛細 <br /> <br /><strong>1. 濡傛灉鎷︽埅鍣ㄥ爢鏍堜腑榪樻湁鍏朵粬鐨処nterceptor錛岄偅涔坕nvocation.invoke()灝嗚皟鐢ㄥ爢鏍堜腑涓嬩竴涓狪nterceptor鐨勬墽琛屻?/strong> <br /> <br /><strong>2. 濡傛灉鎷︽埅鍣ㄥ爢鏍堜腑鍙湁Action浜嗭紝閭d箞invocation.invoke()灝嗚皟鐢ˋction鎵ц銆?/strong> <br /> <br />鎵浠ワ紝鎴戜滑鍙互鍙戠幇錛宨nvocation.invoke()榪欎釜鏂規(guī)硶鍏跺疄鏄暣涓嫤鎴櫒妗嗘灦鐨勫疄鐜版牳蹇冦傚熀浜庤繖鏍風殑瀹炵幇鏈哄埗錛屾垜浠繕鍙互寰楀埌涓嬮潰2涓潪甯擱噸瑕佺殑鎺ㄨ錛?<br /> <br /><strong>1. 濡傛灉鍦ㄦ嫤鎴櫒涓紝鎴戜滑涓嶄嬌鐢╥nvocation.invoke()鏉ュ畬鎴愬爢鏍堜腑涓嬩竴涓厓绱犵殑璋冪敤錛岃屾槸鐩存帴榪斿洖涓涓瓧絎︿覆浣滀負鎵ц緇撴灉錛岄偅涔堟暣涓墽琛屽皢琚腑姝€?/strong> <br /> <br /><strong>2. 鎴戜滑鍙互浠nvocation.invoke()涓虹晫錛屽皢鎷︽埅鍣ㄤ腑鐨勪唬鐮佸垎鎴?涓儴鍒嗭紝鍦╥nvocation.invoke()涔嬪墠鐨勪唬鐮侊紝灝嗕細鍦?Action涔嬪墠琚緷嬈℃墽琛岋紝鑰屽湪invocation.invoke()涔嬪悗鐨勪唬鐮侊紝灝嗕細鍦ˋction涔嬪悗琚嗗簭鎵ц銆?/strong> <br /> <br />鐢辨錛屾垜浠氨鍙互閫氳繃invocation.invoke()浣滀負Action浠g爜鐪熸鐨勬嫤鎴偣錛屼粠鑰屽疄鐜癆OP銆?<br /> <br /><strong><span style="color: blue;">Interceptor鎷︽埅綾誨瀷</span></strong> <br /> <br />浠庝笂闈㈢殑鍒嗘瀽錛屾垜浠煡閬擄紝鏁翠釜鎷︽埅鍣ㄧ殑鏍稿績閮ㄥ垎鏄痠nvocation.invoke()榪欎釜鍑芥暟鐨勮皟鐢ㄤ綅緗備簨瀹炰笂錛屾垜浠篃姝e紡鏍規(guī)嵁榪欏彞浠g爜鐨勮皟鐢ㄤ綅緗紝鏉ヨ繘琛屾嫤鎴被鍨嬬殑鍖哄垎鐨勩傚湪Struts2涓紝Interceptor鐨勬嫤鎴被鍨嬶紝鍒嗘垚浠ヤ笅涓夌被錛?<br /> <br /><strong>1. before</strong> <br /> <br />before鎷︽埅錛屾槸鎸囧湪鎷︽埅鍣ㄤ腑瀹氫箟鐨勪唬鐮侊紝瀹冧滑瀛樺湪浜巌nvocation.invoke()浠g爜鎵ц涔嬪墠銆傝繖浜涗唬鐮侊紝灝嗕緷鐓ф嫤鎴櫒瀹氫箟鐨勯『搴忥紝<strong>欏哄簭鎵ц</strong>銆?<br /> <br /><strong>2. after</strong> <br /> <br />after鎷︽埅錛屾槸鎸囧湪鎷︽埅鍣ㄤ腑瀹氫箟鐨勪唬鐮侊紝瀹冧滑瀛樺湪浜巌nvocation.invoke()浠g爜鎵ц涔嬪悗銆傝繖浜涗唬鐮侊紝灝嗕竴鎷涙嫤鎴櫒瀹氫箟鐨勯『搴忥紝<strong>閫嗗簭鎵ц</strong>銆?<br /> <br />3. PreResultListener <br /> <br />鏈夌殑鏃跺欙紝before鎷︽埅鍜宎fter鎷︽埅瀵規(guī)垜浠潵璇存槸涓嶅鐨勶紝鍥犱負鎴戜滑闇瑕佸湪Action鎵ц瀹屼箣鍚庯紝浣嗘槸榪樻病鏈夊洖鍒拌鍥懼眰涔嬪墠錛屽仛涓浜涗簨 鎯呫係truts2鍚屾牱鏀寔榪欐牱鐨勬嫤鎴紝榪欑鎷︽埅鏂瑰紡錛屾槸閫氳繃鍦ㄦ嫤鎴櫒涓敞鍐屼竴涓狿reResultListener鐨勬帴鍙f潵瀹炵幇鐨勩?<br /> <br /><div class="np5txjj" id=""><div><div>Java浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span>public interface PreResultListener {  </span></li><li>  </li><li>    <span>/** </span></li><li><span>     * This callback method will be called after the Action execution and before the Result execution. </span></li><li><span>     * </span></li><li><span>     * @param invocation </span></li><li><span>     * @param resultCode </span></li><li><span>     */  </span></li><li>    <span>void beforeResult(ActionInvocation invocation, String resultCode);  </span></li><li>}  </li></ol></div> <br /> <br />鍦ㄨ繖閲岋紝鎴戜滑鐪嬪埌錛孲truts2鑳藉鏀寔濡傛澶氱殑鎷︽埅綾誨瀷錛屼笌鍏舵湰韜殑鏁版嵁緇撴瀯鍜屾暣浣撹璁℃湁寰堝ぇ鐨勫叧緋匯傛濡傛垜鍦ㄤ箣鍓嶇殑鏂囩珷涓墍鎻愬埌鐨勶細 <br /> <br /><div>downpour 鍐欓亾</div><div>鍥犱負Action鏄竴涓櫘閫氱殑Java綾伙紝鑰屼笉鏄竴涓猄ervlet綾伙紝瀹屽叏鑴辯浜嶹eb瀹瑰櫒錛屾墍浠ユ垜浠氨鑳藉鏇村姞鏂逛究鍦板Control灞傝繘琛屽悎鐞嗙殑灞傛璁捐錛屼粠鑰屾娊璞″嚭璁稿鍏叡鐨勯昏緫錛屽茍灝嗚繖浜涢昏緫鑴辯鍑篈ction瀵硅薄鏈韓銆?/div> <br /> <br />鎴戜滑鍙互鐪嬪埌錛孲truts2瀵逛簬鏁翠釜鎵ц鐨勫垝鍒嗭紝浠嶪nterceptor鍒癆ction涓鐩村埌Result錛屾瘡涓灞傞兘鑱岃矗鏄庣‘銆備笉浠呭姝わ紝Struts2榪樹負姣忎竴涓眰嬈′箣鍓嶉兘璁劇珛浜嗘伆濡傚叾鍒嗙殑鎻掑叆鐐廣備嬌寰楁暣涓狝ction灞傜殑鎵╁睍鎬у緱鍒頒簡鍙叉棤鍓嶄緥鐨勬彁鍗囥?<br /> <br /><strong><span style="color: blue;">Interceptor鎵ц欏哄簭</span></strong> <br /> <br />Interceptor鐨勬墽琛岄『搴忔垨璁告槸鎴戜滑鍦ㄦ暣涓繃紼嬩腑鏈鏈鍏沖績鐨勯儴鍒嗐傛牴鎹笂闈㈡墍鎻愬埌鐨勬蹇碉紝鎴戜滑瀹為檯涓婂凡緇忚兘澶熷ぇ鑷存槑鐧戒簡Interceptor鐨勬墽琛屾満鐞嗐傛垜浠潵鐪嬬湅Struts2鐨凴eference瀵笽nterceptor鎵ц欏哄簭鐨勪竴涓艦璞$殑渚嬪瓙銆?<br /> <br />濡傛灉鎴戜滑鏈変竴涓猧nterceptor-stack鐨勫畾涔夊涓嬶細 <br /> <br /><div class="nbtxdtz" id=""><div><div>Xml浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span><interceptor-stack name="xaStack">  </span></li><li>  <span><interceptor-ref name="thisWillRunFirstInterceptor"/>  </span></li><li>  <span><interceptor-ref name="thisWillRunNextInterceptor"/>  </span></li><li>  <span><interceptor-ref name="followedByThisInterceptor"/>  </span></li><li>  <span><interceptor-ref name="thisWillRunLastInterceptor"/>  </span></li><li><span></interceptor-stack>  </span></li></ol></div> <br /> <br />閭d箞錛屾暣涓墽琛岀殑欏哄簭澶ф鍍忚繖鏍鳳細 <br /> <br /><img src="http://struts2.group.iteye.com/upload/attachment/71392/23045c94-b72a-3c04-9c6c-06ad4392d743.gif" alt="" /> <br /> <br />鍦ㄨ繖閲岋紝鎴戠◢寰敼浜嗕竴涓婼truts2鐨凴eference涓殑鎵ц欏哄簭紺轟緥錛屼嬌寰楁暣涓墽琛岄『搴忔洿鍔犺兘澶熻鐞嗚В銆傛垜浠彲浠ョ湅鍒幫紝閫掑綊璋冪敤淇濊瘉浜嗗悇縐嶅悇鏍風殑鎷︽埅綾誨瀷鐨勬墽琛岃兘澶熶簳浜曟湁鏉°?<br /> <br />璇鋒敞鎰忓湪榪欓噷錛屾瘡涓嫤鎴櫒涓殑浠g爜鐨勬墽琛岄『搴忥紝鍦ˋction涔嬪墠錛屾嫤鎴櫒鐨勬墽琛岄『搴忎笌鍫嗘爤涓畾涔夌殑涓鑷達紱鑰屽湪Action鍜孯esult涔嬪悗錛屾嫤鎴櫒鐨勬墽琛岄『搴忎笌鍫嗘爤涓畾涔夌殑欏哄簭鐩稿弽銆?<br /> </div> <h2> 婧愮爜瑙f瀽 <a name="1680" ><img alt="Top" src="http://www.iteye.com/images/wiki/top.gif?1324994303" /></a> </h2> 鎺ヤ笅鏉ユ垜浠氨鏉ョ湅鐪嬫簮鐮侊紝鐪嬬湅Struts2鏄浣曚繚璇佹嫤鎴櫒銆丄ction涓嶳esult涓夎呬箣闂寸殑鎵ц欏哄簭鐨勩?<br /> <br />涔嬪墠鎴戞浘緇忔彁鍒幫紝ActionInvocation鏄疭truts2涓殑璋冨害鍣紝鎵浠ヤ簨瀹炰笂錛岃繖浜涗唬鐮佺殑璋冨害鎵ц錛屾槸鍦?ActionInvocation鐨勫疄鐜扮被涓畬鎴愮殑錛岃繖閲岋紝鎴戞娊鍙栦簡DefaultActionInvocation涓殑invoke()鏂規(guī)硶錛屽畠?yōu)畣鍚戞?浠睍紺轟竴鍒囥?<br /> <br /><div class="lzfzdd5" id=""><div><div>Java浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span>/** </span></li><li><span> * @throws ConfigurationException If no result can be found with the returned code </span></li><li><span> */  </span></li><li><span>public String invoke() throws Exception {  </span></li><li>    String profileKey = <span>"invoke: ";  </span></li><li>    <span>try {  </span></li><li>        UtilTimerStack.push(profileKey);  </li><li>              </li><li>        <span>if (executed) {  </span></li><li>            <span>throw new IllegalStateException("Action has already executed");  </span></li><li>        }  </li><li>        <span>// 渚濇璋冪敤鎷︽埅鍣ㄥ爢鏍堜腑鐨勬嫤鎴櫒浠g爜鎵ц  </span></li><li>        <span>if (interceptors.hasNext()) {  </span></li><li>            <span>final InterceptorMapping interceptor = (InterceptorMapping) interceptors.next();  </span></li><li>            UtilTimerStack.profile(<span>"interceptor: "+interceptor.getName(),   </span></li><li>                    <span>new UtilTimerStack.ProfilingBlock<String>() {  </span></li><li>                        <span>public String doProfiling() throws Exception {  </span></li><li>                         <span>// 灝咥ctionInvocation浣滀負鍙傛暟錛岃皟鐢╥nterceptor涓殑intercept鏂規(guī)硶鎵ц  </span></li><li>                            resultCode = interceptor.getInterceptor().intercept(DefaultActionInvocation.<span>this);  </span></li><li>                            <span>return null;  </span></li><li>                        }  </li><li>            });  </li><li>        } <span>else {  </span></li><li>            resultCode = invokeActionOnly();  </li><li>        }  </li><li>  </li><li>        <span>// this is needed because the result will be executed, then control will return to the Interceptor, which will  </span></li><li>        <span>// return above and flow through again  </span></li><li>        <span>if (!executed) {  </span></li><li>            <span>// 鎵цPreResultListener  </span></li><li>            <span>if (preResultListeners != null) {  </span></li><li>                <span>for (Iterator iterator = preResultListeners.iterator();  </span></li><li>                    iterator.hasNext();) {  </li><li>                    PreResultListener listener = (PreResultListener) iterator.next();  </li><li>                          </li><li>                    String _profileKey=<span>"preResultListener: ";  </span></li><li>                    <span>try {  </span></li><li>                            UtilTimerStack.push(_profileKey);  </li><li>                            listener.beforeResult(<span>this, resultCode);  </span></li><li>                    }  </li><li>                    <span>finally {  </span></li><li>                            UtilTimerStack.pop(_profileKey);  </li><li>                    }  </li><li>                }  </li><li>            }  </li><li>  </li><li>            <span>// now execute the result, if we're supposed to  </span></li><li>            <span>// action涓巌nterceptor鎵ц瀹屾瘯錛屾墽琛孯esult  </span></li><li>            <span>if (proxy.getExecuteResult()) {  </span></li><li>                executeResult();  </li><li>            }  </li><li>  </li><li>            executed = <span>true;  </span></li><li>        }  </li><li>  </li><li>        <span>return resultCode;  </span></li><li>    }  </li><li>    <span>finally {  </span></li><li>        UtilTimerStack.pop(profileKey);  </li><li>    }  </li><li>}  </li></ol></div> <br /> <br />浠庢簮鐮佷腑錛屾垜浠彲浠ョ湅鍒幫紝鎴戜滑涔嬪墠鎻愬埌鐨凷truts2鐨凙ction灞傜殑4涓笉鍚岀殑灞傛錛屽湪榪欎釜鏂規(guī)硶涓兘鏈変綋鐜幫紝浠栦滑鍒嗗埆鏄細鎷︽埅鍣?錛圛nterceptor錛夈丄ction銆丳reResultListener鍜孯esult銆傚湪榪欎釜鏂規(guī)硶涓紝淇濊瘉浜嗚繖浜涘眰嬈$殑鏈夊簭璋冪敤鍜屾墽琛屻傜敱姝ゆ垜 浠篃鍙互鐪嬪嚭<strong><span style="color: red;">Struts2鍦ˋction灞傛璁捐涓婄殑浼楀鑰冭檻錛屾瘡涓眰嬈¢兘鍏峰浜嗛珮搴︾殑鎵╁睍鎬у拰鎻掑叆鐐癸紝浣垮緱紼嬪簭鍛樺彲浠ュ湪浠諱綍鍠滄鐨勫眰嬈″姞鍏ヨ嚜宸辯殑瀹炵幇鏈哄埗鏀瑰彉Action鐨勮涓恒?/span></strong> <br /> <br />鍦ㄨ繖閲岋紝闇瑕佺壒鍒己璋冪殑錛屾槸鍏朵腑鎷︽埅鍣ㄩ儴鍒嗙殑鎵ц璋冪敤錛?<br /> <br /><div class="jh31jpj" id=""><div><div>Java浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span>resultCode = interceptor.getInterceptor().intercept(DefaultActionInvocation.this);  </span></li></ol></div> <br /> <br />琛ㄩ潰涓婏紝瀹冨彧鏄墽琛屼簡鎷︽埅鍣ㄤ腑鐨刬ntercept鏂規(guī)硶錛屽鏋滄垜浠粨鍚堟嫤鎴櫒鏉ョ湅錛屽氨鑳界湅鍑虹偣绔潵錛?<br /> <br /><div class="3jdxr5l" id=""><div><div>Java浠g爜  <a title="鏀惰棌榪欐浠g爜"><img src="http://struts2.group.iteye.com/images/icon_star.png" alt="鏀惰棌浠g爜" /></a></div></div><ol start="1"><li><span>public String intercept(ActionInvocation invocation) throws Exception {  </span></li><li>    String result = <span>null;  </span></li><li>  </li><li>        before(invocation);  </li><li>        <span>// 璋冪敤invocation鐨刬nvoke()鏂規(guī)硶錛屽湪榪欓噷褰㈡垚浜嗛掑綊璋冪敤  </span></li><li>        result = invocation.invoke();  </li><li>        after(invocation, result);  </li><li>  </li><li>        <span>return result;  </span></li><li>}  </li></ol></div> <br /> <br />鍘熸潵鍦╥ntercept()鏂規(guī)硶鍙堝ActionInvocation鐨刬nvoke()鏂規(guī)硶榪涜閫掑綊璋冪敤錛孉ctionInvocation 寰幆宓屽鍦╥ntercept()涓紝涓鐩村埌璇彞result = invocation.invoke()鎵ц緇撴潫銆傝繖鏍鳳紝Interceptor鍙堜細鎸夌収鍒氬紑濮嬫墽琛岀殑閫嗗悜欏哄簭渚濇鎵ц緇撴潫銆?/div><img src ="http://www.tkk7.com/hellxoul/aggbug/392970.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/hellxoul/" target="_blank">hellxoul</a> 2012-12-14 10:41 <a href="http://www.tkk7.com/hellxoul/archive/2012/12/14/392970.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://nibayuan.com" target="_blank">国产美女被遭强高潮免费网站</a>| <a href="http://bdykdq.com" target="_blank">黄色片在线免费观看</a>| <a href="http://35419470.com" target="_blank">亚洲国产成人影院播放</a>| <a href="http://9981tv.com" target="_blank">国产精品国产亚洲区艳妇糸列短篇 </a>| <a href="http://whdy888.com" target="_blank">亚洲国产精品日韩在线观看</a>| <a href="http://yidazn.com" target="_blank">蜜桃AV无码免费看永久</a>| <a href="http://0827fang.com" target="_blank">久久精品国产亚洲AV高清热</a>| <a href="http://as5566.com" target="_blank">亚洲精品视频免费在线观看</a>| <a href="http://b7277.com" target="_blank">亚洲人成日本在线观看</a>| <a href="http://lzhuiding.com" target="_blank">性做久久久久久久免费看</a>| <a href="http://scjcled.com" target="_blank">国产成人精品亚洲2020</a>| <a href="http://tha2008.com" target="_blank">在线观看91精品国产不卡免费</a>| <a href="http://yamashida.com" target="_blank">日韩国产欧美亚洲v片</a>| <a href="http://www99383.com" target="_blank">免费人成视频在线观看不卡</a>| <a href="http://jinluffcl.com" target="_blank">www成人免费观看网站</a>| <a href="http://s8sb.com" target="_blank">国产v亚洲v天堂无码网站</a>| <a href="http://quxx28.com" target="_blank">未满十八18禁止免费无码网站</a>| <a href="http://chiguigu.com" target="_blank">亚洲白色白色在线播放</a>| <a href="http://591se591se.com" target="_blank">免费国产作爱视频网站</a>| <a href="http://91se01.com" target="_blank">精品亚洲av无码一区二区柚蜜</a>| <a href="http://wwwse09.com" target="_blank">免费二级毛片免费完整视频</a>| <a href="http://34jjjj.com" target="_blank">精品国产污污免费网站入口</a>| <a href="http://kkxzz.com" target="_blank">日韩亚洲人成在线综合日本</a>| <a href="http://jiggybaby.com" target="_blank">91短视频免费在线观看</a>| <a href="http://3atv3523.com" target="_blank">亚洲日韩亚洲另类激情文学</a>| <a href="http://zhidianzh.com" target="_blank">少妇亚洲免费精品</a>| <a href="http://huianpawn.com" target="_blank">中国性猛交xxxxx免费看</a>| <a href="http://scienfood.com" target="_blank">日韩亚洲AV无码一区二区不卡</a>| <a href="http://jiajuco.com" target="_blank">国内精品免费麻豆网站91麻豆</a>| <a href="http://baocaoluoli.com" target="_blank">亚洲色偷偷色噜噜狠狠99</a>| <a href="http://www-44455588.com" target="_blank">免费jlzzjlzz在线播放视频</a>| <a href="http://microston.com" target="_blank">在线观看免费黄网站</a>| <a href="http://zf91.com" target="_blank">亚洲fuli在线观看</a>| <a href="http://xx9911.com" target="_blank">又大又硬又爽免费视频</a>| <a href="http://chowngroup.com" target="_blank">国产一级黄片儿免费看</a>| <a href="http://doubiseo.com" target="_blank">亚洲免费在线视频播放</a>| <a href="http://426366.com" target="_blank">亚洲国产精品无码久久九九</a>| <a href="http://wwwnewhtbook.com" target="_blank">久久国产精品免费网站</a>| <a href="http://schygfz.com" target="_blank">亚洲精品无码av片</a>| <a href="http://eddiekidd.com" target="_blank">久久91亚洲人成电影网站</a>| <a href="http://km9c.com" target="_blank">天天操夜夜操免费视频</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>