java request uri_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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值