Java知识分享网 - 轻松学习从此开始!    

Java知识分享网

Java1234官方群25:java1234官方群17
Java1234官方群25:838462530
        
SpringBoot+SpringSecurity+Vue+ElementPlus权限系统实战课程 震撼发布        

最新Java全栈就业实战课程(免费)

springcloud分布式电商秒杀实战课程

IDEA永久激活

66套java实战课程无套路领取

锋哥开始收Java学员啦!

Python学习路线图

锋哥开始收Java学员啦!
当前位置: 主页 > Java文档 > JavaWeb技术相关 >

Java EE API(基础包) PDF 下载


分享到:
时间:2021-09-12 10:40来源:http://www.java1234.com 作者:转载  侵权举报
Java EE API(基础包) PDF 下载
失效链接处理
Java EE API(基础包) PDF 下载


本站整理下载:
提取码:wxov 
 
 
相关截图:
 
主要内容:
中⽂简介
定义所有 servlet 都必须实现的⽅法。
servlet 是运⾏在 Web 服务器中的⼩型 Java 程序。servlet 通常通过 HTTP(超⽂本传输协议)接收和响应来⾃
Web 客户端的请求。
public interface Servlet
要实现此接⼝,可以编写⼀个扩展 javax.servlet.GenericServlet 的⼀般 servlet,或者编写⼀个扩展
javax.servlet.http.HttpServlet 的 HTTP servlet。
此接⼝定义了初始化 servlet 的⽅法、为请求提供服务的⽅法和从服务器移除 servlet 的⽅法。这些⽅法称为⽣命周
期⽅法,它们是按以下顺序调⽤的:
1. 构造 servlet,然后使⽤ init ⽅法将其初始化。
2. 处理来⾃客户端的对 service ⽅法的所有调⽤。
3. 从服务中取出 servlet,然后使⽤ destroy ⽅法销毁它,最后进⾏垃圾回收并终⽌它。
除了⽣命周期⽅法之外,此接⼝还提供了 getServletConfig ⽅法和 getServletInfo ⽅法,servlet 可使⽤前
⼀种⽅法获得任何启动信息,⽽后⼀种⽅法允许 servlet 返回有关其⾃身的基本信息,⽐如作者、版本和版权。
⽅法总结
destroy
Called by the servlet container to indicate to a servlet that the servlet is being taken out of service. This
method is only called once all threads within the servlet's service method have exited or after a timeout
period has passed. After the servlet container calls this method, it will not call the service method again
on this servlet.
This method gives the servlet an opportunity to clean up any resources that are being held (for example,
memory, file handles, threads) and make sure that any persistent state is synchronized with the servlet's
current state in memory.
由 servlet 容器调⽤,指示将从服务中取出该 servlet。此⽅法仅在 servlet 的 service ⽅法已退出或者在过了超
时期之后调⽤⼀次。在调⽤此⽅法之后,servlet 容器不会再对此 servlet 调⽤ service ⽅法。
此⽅法为 servlet 提供了⼀个清除持有的所有资源(⽐如内存、⽂件句柄和线程)的机会,并确保任何持久状态
都与内存中该 servlet 的当前状态保持同步。
void destroy()
getServletConfig
Returns a ServletConfig object, which contains initialization and startup parameters for this servlet. The
ServletConfig object returned is the one passed to the init method.
Implementations of this interface are responsible for storing the ServletConfig object so that this method
can return it. The GenericServlet class, which implements this interface, already does this.
Returns:
the ServletConfig object that initializes this servlet
 返回 ServletConfig 对象,该对象包含此 servlet 的初始化和启动参数。返回的 ServletConfig 对象是传递给 init
⽅法的对象。
 此接⼝的实现负责存储 ServletConfig 对象,以便此⽅法可以返回该对象。实现此接⼝的 GenericServlet 类已经
这样做了。
return初始化此 servlet 的 ServletConfig 对象
getServletInfo
Returns information about the servlet, such as author, version, and copyright.
The string that this method returns should be plain text and not markup of any kind (such as HTML, XML,
etc.).
Returns:
a String containing servlet information
返回有关 servlet 的信息,⽐如作者、版本和版权。
此⽅法返回的字符串应该是纯⽂本,不应该是任何种类的标记(⽐如 HTML、XML,等等)。
return包含 servlet 信息的 String
init
Called by the servlet container to indicate to a servlet that the servlet is being placed into service.
The servlet container calls the init method exactly once after instantiating the servlet. The init method
must complete successfully before the servlet can receive any requests.
The servlet container cannot place the servlet into service if the init method
1. Throws a ServletException
2. Does not return within a time period defined by the Web server
ServletConfig getServletConfig()
String getServletInfo()
void init(ServletConfig config)
 throws ServletException
Parameters:
config - a ServletConfig object containing the servlet's configuration and initialization parameters
Throws:
ServletException - if an exception has occurred that interferes with the servlet's normal operation
 由 servlet 容器调⽤,指示将该 servlet 放⼊服务。
 servlet 容器仅在实例化 servlet 之后调⽤ init ⽅法⼀次。在 servlet 可以接收任何请求之前,init ⽅法必须成功完
成。
 servlet 容器⽆法将 servlet 放⼊服务,如果 init ⽅法:
1. 抛出 ServletException
2. 未在 Web 服务器定义的时间段内返回
参数
config 包含 servlet 的配置和初始化参数的 ServletConfig 对象
异常
Throws ServletException: 如果发⽣妨碍 servlet 正常操作的异常
service
Called by the servlet container to allow the servlet to respond to a request.
This method is only called after the servlet's init() method has completed successfully.
The status code of the response always should be set for a servlet that throws or sends an error.
Servlets typically run inside multithreaded servlet containers that can handle multiple requests
concurrently. Developers must be aware to synchronize access to any shared resources such as files,
network connections, and as well as the servlet's class and instance variables. More information on
multithreaded programming in Java is available in the Java tutorial on multi-threaded programming.
Parameters:
req - the ServletRequest object that contains the client's request
res - the ServletResponse object that contains the servlet's response
Throws:
ServletException - if an exception occurs that interferes with the servlet's normal operation
IOException - if an input or output exception occurs
由 servlet 容器调⽤,以允许 servlet 响应某个请求。
此⽅法仅在 servlet 的 init() ⽅法成功完成之后调⽤。
void service(ServletRequest req,
 ServletResponse res)
 throws ServletException,
 IOException
应该为抛出或发送错误的 servlet 设置响应的状态代码。
servlet 通常运⾏在可同时处理多个请求的多线程 servlet 容器中。开发⼈员必须知道要同步对所有共享资源(⽐
如⽂件、⽹络连接以及 servlet 的类和实例变量)的访问。有关 Java 中多线程编程的更多信息,可从 the Java
tutorial on multi-threaded programming 中获得。
参数
req 包含客户端请求的 ServletRequest 对象
res 包含 servlet 的响应的 ServletResponse 对象
异常
Throws ServletException: 如果发⽣妨碍 servlet 正常操作的异常
Throws java.io.IOException: 如果发⽣输⼊或输出异常
ServletRequest
英⽂简介
Defines an object to provide client request information to a servlet. The servlet container creates a
ServletRequest object and passes it as an argument to the servlet's service method.
A ServletRequest object provides data including parameter name and values, attributes, and an input
stream. Interfaces that extend ServletRequest can provide additional protocol-specific data (for example,
HTTP data is provided by HttpServletRequest .
中⽂简介
定义将客户端请求信息提供给某个 servlet 的对象。servlet 容器创建 ServletRequest 对象,并将该对象作为参
数传递给该 servlet 的 service ⽅法。
ServletRequest 对象提供包括参数名称、参数值、属性和输⼊流的数据。扩展 ServletRequest 的接⼝可提供
其他特定于协议的数据,例如 javax.servlet.http.HttpServletRequest 提供的 HTTP 数据。
⽅法总结

 

------分隔线----------------------------

锋哥公众号


锋哥微信


关注公众号
【Java资料站】
回复 666
获取 
66套java
从菜鸡到大神
项目实战课程

锋哥推荐