首页 > 代码库 > 子类 父类强转 HttpServlet service实现

子类 父类强转 HttpServlet service实现

相当于 走父类 临时走了一趟

HttpServletRequest ->ServletRequets -> HttpServeltRequest

 

/*     */   public void service(ServletRequest req, ServletResponse res)
/*     */     throws ServletException, IOException
/*     */   {
/*     */     HttpServletRequest request;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     HttpServletResponse response;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */     try
/*     */     {
/* 663 */       request = (HttpServletRequest)req;
/* 664 */       response = (HttpServletResponse)res;
/*     */     } catch (ClassCastException e) {
/* 666 */       throw new ServletException("non-HTTP request or response");
/*     */     }
/* 668 */     service(request, response);
/*     */   }
/*     */ }

 

子类 父类强转 HttpServlet service实现