首页 > 其他分享 >Servlet_urlpartten配置以及HTTP_概述

Servlet_urlpartten配置以及HTTP_概述

时间:2022-12-02 19:00:44浏览次数:54  
标签:HTTP ServletException resp WebServlet IOException urlpartten Servlet void

Servlet_urlpartten配置

urlpartten:Servlet访问路径

  1.、一个Servlet可以定义多个访问路径

@WebServlet({"/demo5","d5"})
public class ServletDemo5 extends 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...");
    }
}

  2.路径定义规则:

    1./xxx:路径匹配

    2./xxx/xxx:多层路径,目录结构

    3.*.do:扩展名匹配

//@WebServlet({"/demo5","d5"})
//@WebServlet("/user/demo5")
//@WebServlet("/user/*") // * :通配符
//@WebServlet("/*")
@WebServlet("*.do")
public class ServletDemo5 extends 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...");
    }
}

 

 

 

 

HTTP_概述

概念:Hyper  Text  Transfer  Protocol:超文本传输协议

  传输协议:定义了,客户端和服务端通信时,发送数据的格式

  特点:

    1.基于TCP/IP的高级协议

    2.默认端口号:8080

      http:www.itcast.cn:8080

    3.基于请求响应模型的:一次请求对应一次响应

    4.无状态的:每次请求之间相互独立,不能交互数据

 历史版本:

    1.0:每一次请求响应都会建立新的连接

    1.1:复用连接

 

标签:HTTP,ServletException,resp,WebServlet,IOException,urlpartten,Servlet,void
From: https://www.cnblogs.com/qihaokuan/p/16945384.html

相关文章