sevlet API部分说明

 

servlet接口中的方法:

void init(ServletConfig config) throws ServletException:第一次加载servlet时仅调用一次。

ServletConfig getServletConfig():返回传递到init()方法的ServletConfig对象。

void service(ServletRequest request,ServletResponse response) throws :处理request对象中描述的请求,使用response对象返回请求结果。

ServletException, IOException

String getServletInfo():返回描述servlet的一个字符串。

void destory():当servlet将要卸载时由sevlet引擎调用。

 


 

GenericServlet类中的方法:

void destory():

String getInitParameter(String name):返回具有指定名称的初始化参数值。通过调用config.getInitParameter(name)实现。

Enumeration getInitParameterNames():返回所有初始化参数的一个枚举类型值。如果没有,则返回空枚举。

ServletConfig getServletConfig():返回传递到init()方法中的config对象

ServletContext getServletContext():返回在config对象中引用的ServletContext

String getServletInfo():返回空字符串

void init(ServletConfig config) throws ServletException:在一实例变量中保存config对象

void init() throws ServletException:

void log(String msg):编写注册servlet的入口。为此调用servlet上下文的log方法。

void log(String msg,Throwable t):

abstract void service(Request request,Response response):由servlet引擎调用为请求对象描述的请求提供服务。必须被子类覆盖

throws ServeltException,IOException

String getServletName():返回在web应用发布描述其(web.xml)中指定的servlet名字

 

 


 

HttpServlet类中的方法

void doGet(HttpServletRequest request,HttpServletResponse response):处理GET请求。

throws SerlvetException,IOException

void doPost(HttpServletRequest request,HttpServletResponse response):处理POST请求。

throws SerlvetException,IOException

void doPut(HttpServletRequest request,HttpServletResponse response):处理PUT求情,本方法中请求URI指出被载入的文件位置

throws SerlvetException,IOException

void doDelete(HttpServletRequest request,HttpServletResponse response):处理DELETE请求,清楚URI指出资源被删除

throws SerlvetException,IOException

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值