JSP(2)--Servlet解析

1.具体结构

2.重要接口源码

(1)Servlet:

public void init(ServletConfig config) ;
public ServletConfig getServletConfig();
public void service(ServletRequest req, ServletResponse res);
public String getServletInfo();
public void destroy();

(2)ServletConfit

一些Servlet配置信息

public String getServletName();
public ServletContext getServletContext();
public String getInitParameter(String name);
public Enumeration<String> getInitParameterNames();

(3)ServletContext

Servlet上下文

public String getContextPath();
public int getMajorVersion();
public int getMinorVersion();
public String getMimeType(String file);
...........

3.Servlet的生命周期

1.用户请求服务器是加载Servlet(可以在web.xml里面设置服务器初始化是打开)

2.init()

3.调用Service() 处理请求,重写doGET ,doPOST

4.返回结果

5.Web容器关闭时destroy()

猜你喜欢

转载自www.cnblogs.com/blogofjzq/p/9234015.html
今日推荐