前言:上学期学得JAVAWeb到了复习的时候了。
现在我上学期学得加上寒假偷偷去学得SHH框架全部在博客记录下来吧。
好在以后自己不记得了也能快速的记起来~
后语:基友们过年别撸了!和爸妈聊聊天
好,这次是自己回忆Servlet中的相关
1、Serlvet就是运行在Web服务器端(我常用apache)的Java程序。它是可以接受和回应浏览器的请求,通过使用HTTP协议进行啪啪啪!
这是一段Servlet
Java
package servlet;
import java.io.IOException;
import java.io.PrintWriter;
public class LoginServlet extends HttpServlet {
public LoginServlet() {
super();
}
public void destroy() {
super.destroy();
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
this.doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
public void init() throws ServletException {
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
packageservlet;
importjava.io.IOException;
importjava.io.PrintWriter;
publicclassLoginServletextendsHttpServlet{
publicLoginServlet(){
super();
}
publicvoiddestroy(){
super.destroy();
}
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException{
this.doPost(request,response);
}
publicvoiddoPost(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException{
}
}
publicvoidinit()throwsServletException{
}
}
1、init()方法,用于初始化测试.
2、destroyed()方法,是被销毁的时候调用
3、getServletConfig()方法,可以获取当前Servlet设置信息和初始化Servlet是通过web.xml配置文件传入参数。
4、getServletInfo()方法,返回相关Servlet的信息
其他详情百度!
the end!
从清远这里的招聘,我是越来越脱离了IT这个行业了!