GenericServlet类:将Servlet类当中除了service方法之外的其他方法做了空实现,只有service作为抽象方法
HttpServlet类(对HTTP协议的封装和学习)(推荐使用!):
实现请求方式“Get”和“Post”的判断:doGet()和doPost()方法
对HTTP协议的一种封装,简化操作
HttpServlet的使用方法:
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("doGet...");
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
System.out.println("doPost...");
}
<!--login.html-->
<body>
<form action = "/day_servlet/demo" method = "post">
<input name = "username">
<input type = "submit" value = "submit">
</form>
</body>