[JAVA] HttpServletRequest.getServletPath()取得的路径
如果项目名称为PCBossMgr,你在浏览器中输入请求路径为:http://localhost:8080/PCBossMgr/login/showWelcome.html
那么,
属性 | 返回值 |
request.getRequestURL().toString() | http://localhost:8080/PCBossMgr/login/showWelcome.html |
request.getRequestURI() | /PCBossMgr/login/showWelcome.html |
request.getServletPath() | /login/showWelcome.html |
request.getContextPath() | PCBossMgr |
request.getServerName() | localhost |
| |
[C#] Uri属性示例
new Uri("http://local:82/1.htm") new Uri("http://buguge.com/gLyric/Search.aspx?key=0%u4e00%u6b65")
.AbsolutePath : /1.htm /gLyric/Search.aspx
.AbsoluteUri : http://local:82/1.htm http://buguge.com/gLyric/Search.aspx?key=0%u4e00%u6b65
.Authority : local:82 buguge.com
.Query : "" ?key=0%u4e00%u6b65
.DnsSafeHost : local buguge.com
.Host : local buguge.com
.IsAbsoluteUri : true true
.IsDefaultPort : false true
.LocalPath : /1.htm /gLyric/Search.aspx
.OriginalString : http://local:82/1.htm http://buguge.com/gLyric/Search.aspx?key=0%u4e00%u6b65
.Port : 82 80
.Scheme : http http
Request.RawUrl和Request.Url的区别:
假设访问地址是: | http://localhost/cftea/Default.aspx?p1=?&p2=%3f | 区别 |
那么,Request.RawUrl: | /cftea/Default.aspx?p1=?&p2=%3f | ●不包含主机名及前面的内容●完整地体现地址栏的 QueryString●Request.RawUrl是string类型 |
那么,Request.Url: | http://localhost/cftea/Default.aspx?p1=?&p2=? | ●包含主机名及前面的内容;●会进行 Server.URLDecode 解析●Request.Url的类型是Uri
|
当看到一些不好的代码时,会发现我还算优秀;当看到优秀的代码时,也才意识到持续学习的重要!--buguge