Servlet体系结构

我只是一个虾纸丫 提交于 2020-01-26 02:19:58

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>

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!