HttpServlet类? 定义? public?? class?? HttpServlet?? extends?? GenericServlet? implements? Serializable? 这是一个抽象类,用来简化HTTP?? Servlet写作的过程。它是GenericServlet类的扩充,提供了一个处理HTTP协议的框架。??
????????????? 在这个类中的service方法支持例如GET、POST这样的标准的HTTP方法。这一支持过程是通过分配他们到适当的方法(例如doGet、doPost)来实现的。??
????????????? 方法??
????????????? 1、doDelete??
????????????? protected?? void?? doDelete(HttpServletRequest?? request,??
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? DELETE操作。这个操作允许客户端请求从服务器上删除URL。这一操作可能有负面影响,对此用户就负起责任。??
????????????? 这一方法的默认执行结果是返回一个HTTP?? BAD_REQUEST错误。当你要处理DELETE请求时,你必须重载这一方法。??
????????????? 2、doGet??
????????????? protected?? void?? doGet(HttpServletRequest?? request,????
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? GET操作。这个操作允许客户端简单地从一个HTTP服务器“获得”资源。对这个方法的重载将自动地支持HEAD方法。??
????????????? GET操作应该是安全而且没有负面影响的。这个操作也应该可以安全地重复。??
????????????? 这一方法的默认执行结果是返回一个HTTP?? BAD_REQUEST错误。??
????????????? 3、doHead??
????????????? protected?? void?? doHead(HttpServletRequest?? request,??
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? HEAD操作。默认的情况是,这个操作会按照一个无条件的GET方法来执行,该操作不向客户端返回任何数据,而仅仅是返回包含内容长度的头信息。??
????????????? 与GET操作一样,这个操作应该是安全而且没有负面影响的。这个操作也应该可以安全地重复。??
????????????? 这个方法的默认执行结果是自动处理HTTP?? HEAD操作,这个方法不需要被一个子类执行。????
????????????? 4、doOptions??
????????????? protected?? void?? doOptions(HttpServletRequest?? request,??
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? OPTION操作。这个操作自动地决定支持哪一种HTTP方法。例如,一个Servlet写了一个HttpServlet的子类并重载了doGet方法,doOption会返回下面的头:??
????????????? Allow:?? GET,HEAD,TRACE,OPTIONS??
????????????? 你一般不需要重载这个方法。??
????????????? 5、doPost??
????????????? protected?? void?? doPost(HttpServletRequest?? request,??
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? POST操作。这个操作包含请求体的数据,Servlet应该按照他行事。??
????????????? 这个操作可能有负面影响。例如更新存储的数据或在线购物。??
????????????? 这一方法的默认执行结果是返回一个HTTP?? BAD_REQUEST错误。当你要处理POST操作时,你必须在HttpServlet的子类中重载这一方法。??
????????????? 6、doPut??
????????????? protected?? void?? doPut(HttpServletRequest?? request,????
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? PUT操作。这个操作类似于通过FTP发送文件。??
????????????? 这个操作可能有负面影响。例如更新存储的数据或在线购物。??
????????????? 这一方法的默认执行结果是返回一个HTTP?? BAD_REQUEST错误。当你要处理PUT操作时,你必须在HttpServlet的子类中重载这一方法。??
????????????? 7、doTrace??
????????????? protected?? void?? doTrace(HttpServletRequest?? request,??
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? 被这个类的service方法调用,用来处理一个HTTP?? TRACE操作。这个操作的默认执行结果是产生一个响应,这个响应包含一个反映trace请求中发送的所有头域的信息。??
????????????? 当你开发Servlet时,在多数情况下你需要重载这个方法。??
????????????? 8、getLastModified??
????????????? protected?? long?? getLastModified(HttpServletRequest?? request);??
????????????? 返回这个请求实体的最后修改时间。为了支持GET操作,你必须重载这一方法,以精确地反映最后修改的时间。这将有助于浏览器和代理服务器减少装载服务器和网络资源,从而更加有效地工作。返回的数值是自1970-1-1日(GMT)以来的毫秒数。????
? 默认的执行结果是返回一个负数,这标志着最后修改时间未知,它也不能被一个有条件的GET操作使用。??
????????????? 9、service??
????????????? protected?? void?? service(HttpServletRequest?? request,??
????????????????????????? HttpServletResponse?? response)?? throws?? ServletException,??
????????????????????????? IOException;??
????????????? public?? void?? service(ServletRequest?? request,?? ServletResponse?? response)??
????????????????????????? throws?? ServletException,?? IOException;??
????????????? 这是一个Servlet的HTTP-specific方案,它分配请求到这个类的支持这个请求的其他方法。??
????????????? 当你开发Servlet时,在多数情况下你不必重载这个方法。??
详细解决方案
HttpServlet种
热度:138 发布时间:2012-11-23 00:03:29.0
相关解决方案
- 施用 acl_cpp 的 HttpServlet 类及 google 的 ctemplate 库编写 WEB 应用
- HttpServlet Web 通信
- 运用 acl_cpp 的 HttpServlet 类及服务器框架编写WEB服务器程序
- at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
- 异常:HttpServlet was not found on the Java
- javax.httpServlet,该怎么解决
- eclipse jsp报错 superclass javax.servlet.http.HttpServlet was not found on the Java Build Path
- Java错误:The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path的解决方法
- The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path错误解决
- HttpServlet:此URL不支持HTTP方法GET HTTP status 405
- JSP异常 The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path 解决
- Servlet系列学习笔记3--- HttpServlet
- jsp出现The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path
- The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path错误解决办法
- [Jweb] Servlet 生命周期, TestLifeCycleServlet extends HttpServlet
- [Jweb] Servlet / GenericServlet / HttpServlet 及其方法示意图
- eclipse新建jsp报错The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path
- HttpServlet:此URL不支持HTTP方法POST ——问题解决
- java异常:The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path。
- HttpServlet- 读取表单参数GetPost
- JavaWeb报错:The superclass javax.servlet.http.HttpServlet was not found on the Java Build Path
- Resource Path Location Type The superclass javax.servlet.http.HttpServlet was not found解决方法
- Myeclipse中关于The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
- eclipse/jsp页面:报错The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path
- eclipse 创建servlet 出现继承 HttpServlet 报红线
- jsp页面提示“Multiple annotations found at this line: - The superclass javax.servlet.http.HttpServlet w
- 刚创建的Maven项目的.jsp文件报he superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Pa
- 解决 “The superclass “javax.servlet.http.HttpServlet“ was not found on the Java Build Path”
- 用户登录实现(Tomcat、HttpServlet、JDBC、Mysql、Navicat)
- HttpServlet