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
轉載于:https://www.cnblogs.com/Mike_Chang/p/10022041.html
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的requestURI的组成部分的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CSS 实现隐藏滚动条同时又可以滚动
- 下一篇: day08 MapReduce