亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

對(duì)handlerexecutionchain類的深入理解

 更新時(shí)間:2017年07月04日 08:36:07   投稿:jingxian  
下面小編就為大家?guī)?lái)一篇對(duì)handlerexecutionchain類的深入理解。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧

HandlerExecutionChain類比較簡(jiǎn)單,好理解。

/*
 * 處理器執(zhí)行鏈由處理器對(duì)象和攔截器組成。
 */
public class HandlerExecutionChain {

下面是類的部分屬性。

private final Object handler; //處理器對(duì)象。

  private HandlerInterceptor[] interceptors; //攔截器數(shù)組

  private List<HandlerInterceptor> interceptorList; //攔截器列表
/**
   * Apply preHandle methods of registered interceptors.
   * @return {@code true} if the execution chain should proceed with the
   * next interceptor or the handler itself. Else, DispatcherServlet assumes
   * that this interceptor has already dealt with the response itself.
   * 執(zhí)行已經(jīng)注冊(cè)的攔截的 preHandle()方法。如果返回true,則執(zhí)行鏈可以執(zhí)行下一個(gè)攔截器的preHandle()方法或 handler 自身。
   * 否則,
   */
  boolean applyPreHandle(HttpServletRequest request, HttpServletResponse response) throws Exception {
    HandlerInterceptor[] interceptors = getInterceptors();
    if (!ObjectUtils.isEmpty(interceptors)) {
      for (int i = 0; i < interceptors.length; i++) {
        HandlerInterceptor interceptor = interceptors[i];
        if (!interceptor.preHandle(request, response, this.handler)) {
          triggerAfterCompletion(request, response, null);
          return false;
        }
        this.interceptorIndex = i;
      }
    }
    return true;
  }
/*
   * 執(zhí)行已經(jīng)注冊(cè)的攔截器 postHandle()方法。
   */
  void applyPostHandle(HttpServletRequest request, HttpServletResponse response, ModelAndView mv) throws Exception {
    HandlerInterceptor[] interceptors = getInterceptors();
    if (!ObjectUtils.isEmpty(interceptors)) {
      for (int i = interceptors.length - 1; i >= 0; i--) {
        HandlerInterceptor interceptor = interceptors[i];
        interceptor.postHandle(request, response, this.handler, mv);
      }
    }
  }
/**
   * 這個(gè)方法只會(huì)執(zhí)行preHandle()方法已經(jīng)成功執(zhí)行并且返回true的攔截器中的postHandle()方法。
   */
  void triggerAfterCompletion(HttpServletRequest request, HttpServletResponse response, Exception ex)
      throws Exception {

    HandlerInterceptor[] interceptors = getInterceptors();
    if (!ObjectUtils.isEmpty(interceptors)) {
      for (int i = this.interceptorIndex; i >= 0; i--) {
        HandlerInterceptor interceptor = interceptors[i];
        try {
          interceptor.afterCompletion(request, response, this.handler, ex);
        }
        catch (Throwable ex2) {
          logger.error("HandlerInterceptor.afterCompletion threw exception", ex2);
        }
      }
    }
  }

以上這篇對(duì)handlerexecutionchain類的深入理解就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • java“與”符號(hào)寫法與用法

    java“與”符號(hào)寫法與用法

    在本篇文章里小編給大家整理的是關(guān)于java“與”符號(hào)寫法與用法,對(duì)此有需要的朋友們可以學(xué)習(xí)下。
    2020-02-02
  • SpringMVC和Ajax的交互詳解(手工處理)

    SpringMVC和Ajax的交互詳解(手工處理)

    Ajax即異步的?JavaScript和XML,是一種無(wú)需重新加載整個(gè)網(wǎng)頁(yè)的情況下,能夠更新部分模塊的網(wǎng)頁(yè)技術(shù),下面這篇文章主要給大家介紹了關(guān)于SpringMVC和Ajax交互的相關(guān)資料,文中通過(guò)實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-08-08
  • 徹底理解Java中this 關(guān)鍵字

    徹底理解Java中this 關(guān)鍵字

    這篇文章主要介紹了徹底理解Java中this 關(guān)鍵字的相關(guān)資料,非常不錯(cuò),具有參考價(jià)值,需要的朋友可以參考下
    2016-05-05
  • SpringMVC中DispatcherServlet的HandlerMapping詳解

    SpringMVC中DispatcherServlet的HandlerMapping詳解

    這篇文章主要介紹了SpringMVC中DispatcherServlet的HandlerMapping詳解,上回說(shuō)的Handler,我們說(shuō)是處理特定請(qǐng)求的,也就是說(shuō),不是所有的請(qǐng)求都能處理,那么問(wèn)題來(lái)了,我們?cè)踔滥膫€(gè)請(qǐng)求是由哪個(gè)Handler處理的呢,需要的朋友可以參考下
    2023-10-10
  • 最新評(píng)論