java 的url类中有很多get方法

以下是获取值的意义

// 首先先看一下wikipedia上关于url的一个描述

//Every HTTP URL conforms to the syntax of a generic URI. A generic URI is of the form:

 scheme:[//[user:password@]host[:port]][/]path[?query][#fragment]

一个完整的 url 是由上面这些字段组成的。一般情况下我们访问的网络没有用户名密码验证,所以都没有输user:password

以下是在开发环境中对一个完整的url的输出的测试

String urlStr = "http://tester:123456@www.baidu.com?a=b&b=c&c=d#abc";

URL url = new URL(urlStr);

String protocol = url.getProtocol();

protocol is http
host is www.baidu.com
port is -1
default port is 80 query is a=b&b=c&c=d
ref is abc
user is tester:123456
authority is tester:123456@www.baidu.com
file is ?a=b&b=c&c=d

content is sun.net.www.protocol.http.HttpURLConnection$HttpInputStream@1f89ab83

 



相关文章:

  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-14
  • 2022-02-22
  • 2022-12-23
  • 2021-12-02
相关资源
相似解决方案