zoukankan      html  css  js  c++  java
  • requestURI的组成部分

    使用 java EE HttpServletRequest对象获取的

    request.getRequestURL();
    request.getRequestURI();
    request.getContextPath();
    request.getServletPath();
    request.getPathInfo();

    ContextPath配置为hello,ServletPath配置为/*

    输出:

    URL: http://127.0.0.1:8001/hello/world/5555
    URI: /hello/world/5555
    contextPath: /hello
    servletPath: 
    pathInfo: /world/5555

    1、URL包括 ip地址和端口号

    2、URI不包括 ip地址和端口号

    3、contextPath是web容器——比如tomcat用来决定调用wabapps下的哪个项目的,因为一个web容器可以部署多个项目

    4、servletPath就是我们配置的servlet的映射路径

    5、pathInfo是我们配置的servlet的映射路径被通配符代替的部分


    具体说明 

    假如contextPath是hello,servlet映射路径配置不同对servletPath和pathInfo的影响:

    (1)servletPath配置为 /world/*,我们访问的地址为 127.0.0.1:8080/hello/world/4444

        servletPath: /world
        pathInfo: /4444

    (2)servletPath配置为 /,我们访问的地址为 127.0.0.1:8080/hello/world/6666

        servletPath: /world/6666
        pathInfo: null

  • 相关阅读:
    java第一次作业
    第十一次作业
    第十次作业
    第九次作业
    第八次作业
    第七次作业
    第六次作业
    第五次作业
    实验四,实验五
    Java_实验二
  • 原文地址:https://www.cnblogs.com/Mike_Chang/p/10022041.html
Copyright © 2011-2022 走看看