问题描述
我正在寻找 javax.servlet.http.HttpServlet
, javax.servlet.GenericServlet $ c之间的确切区别$ c>和
javax.Servlet
无法找到它。
I was searching for exact difference between javax.servlet.http.HttpServlet
, javax.servlet.GenericServlet
and javax.Servlet
unable to find it out.
完全差异是指
- 用法
-
背后的原因javax.servlet.GenericServlet
存在
- Usage
- Reason behind
javax.servlet.GenericServlet
existence
推荐答案
确切的差异意味着什么? API会列出完全差异。
"Exact difference" meaning what? The API lists the exact differences.
Servlet
is an interface defining what a servlet must implement.
GenericServlet
is just that, a generic, protocol-independent servlet.
HttpServlet
is a servlet tied specifically to the HTTP protocol.
您是否在询问何时使用其中任何一个?
Are you asking when you'd use any of those?
通常,您需要扩展 HttpServlet
来实现应用程序的Web层。
In general, you'd extend HttpServlet
to implement an application's web layer.
如果您正在编写自己的容器或自行处理所有内容,则可以实现 Servlet
。你可以扩展 GenericServlet
来处理不同的协议,但你可能不会。
You might implement Servlet
if you're writing your own container or handling everything yourself. You might extend GenericServlet
to handle a different protocol, but you might not.
这篇关于GenericServlet,HttpServlet和Servlet有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!