hello2代码的简单分析

hello2部分代码:

  

  String username = request.getParameter("username");//将get~这个方法赋给username这个对象
  if (username != null && username.length() > 0) {
  RequestDispatcher dispatcher =getServletContext().getRequestDispatcher("/response");//定义接收来自客户端的请求并将它们发送到服务器上的任何资源的对象dispatcher
                                          //该对象被用作包装位于特定路径上的服务器资源或通过特定名称给定的服务器资源的包装器
       if (dispatcher != null) {
  dispatcher.include(request, response);
  }
  }
  out.println("</body></html>");//判dispatcher这个对象的值是否为空,并返回输出
  }
  }

  @Override// 伪代码,表示重写
  public String getServletInfo() {
  return "The Hello servlet says hello.";//返回hello最后的输出

  }
  }

原文地址:https://www.cnblogs.com/zhuguohui/p/10590962.html