servlet是Java的处理响应的接口,HttpServlet是Servlet的子类
void service(ServletRequest request , ServletResponse response)
参数:
ServletRequest request:客户端请求对象
ServletResponse response: 服务器响应对象
返回值:void
返回值意义:无
作用: servlet 响应某个请求。
void doGet(HttpServletRequest request HttpServletResponse response)
参数:
HttpServletRequest request:客户端请求对象
HttpServletResponse response:服务器响应对象
返回值:void
返回值意义:无
作用:由servlet.service() 调用,让servlet处理doGet()方法
void doPost(HttpServletRequest request , HttpServletResponse response)
参数:
HttpServletRequest request:客户端请求对象
HttpServletResponse response:服务器响应对象
返回值:void
返回值意义:无
作用:由servlet.service() 调用,让servlet处理doPost()方法
HttpServlet.service()是处理请求的方法,不过是由Servlet容器调用。通过编写doGet()方法或doPost()方法让HttpServlet.service()处理对应请求