Ejemplo n.º 1
0
 @Override
 public void afterCompletion(
     HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
     throws Exception {
   System.out.println(this.getClass().getSimpleName() + "---afterCompletion()...");
   long endTime = System.currentTimeMillis();
   long beginTime = starTimeThreadLocal.get();
   long consumeTime = endTime - beginTime;
   System.out.println("consumeTime=" + consumeTime);
   super.afterCompletion(request, response, handler, ex);
 }
  @Override
  public void afterCompletion(
      HttpServletRequest _request, HttpServletResponse _response, Object _handler, Exception _ex)
      throws Exception {
    // TODO Auto-generated method stub

    long endTime = System.currentTimeMillis(); // 2、结束时间
    long beginTime = startTimeThreadLocal.get(); // 得到线程绑定的局部变量(开始时间)
    long consumeTime = endTime - beginTime; // 3、消耗的时间
    // System.out.println(consumeTime);
    if (consumeTime > 500) { // 此处认为处理时间超过500毫秒的请求为慢请求
      System.out.println(
          String.format("%s consume %d millis", _request.getRequestURI(), consumeTime));
    }
    log.info(_ex);
    super.afterCompletion(_request, _response, _handler, _ex);
  }