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

  • 相关阅读:
    Demo:刮刮卡橡皮擦效果
    养成良好的代码编写习惯
    我的百科
    专业英语词汇
    加载资源的类
    循环滚动翻页+居中项缩放
    学习笔记—Node中模块化规范
    学习笔记—Node中的EventLoop
    学习笔记—Node的全局对象
    学习笔记—Node的基本概念
  • 原文地址:https://www.cnblogs.com/Mike_Chang/p/10022041.html
Copyright © 2011-2022 走看看