Servlet的三种编写方式(HttpServlet)
/**
* HttpServlet(模板设计模式)
*
* @author JerichoPH
*/
public class ServletDemo3 extends HttpServlet {
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("**********GET**********");
System.out.println(req.getRemoteAddr()); // 获取访问者地址信息
}
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println("**********POST**********");
}
}