星期三

关于servlet

servlet用于处理前端的请求并反应,实现前端与数据库的对接

创建一个类继承HttpServlet类

public class ServletDemo3 extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        System.out.println("haha");
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        System.out.println("ee");
        doGet(req,resp);
    }

}
get和post分别是接到请求的两种方法,方法中的request对象和response对象分别用于请求和响应
posted @ 2023-09-27 14:11  umiQa  阅读(11)  评论(0编辑  收藏  举报