第十四章 其他InterSystems %Net工具
下面是%Net中其他一些有用类的简短列表:
%Net.URLParser
InterSystems IRIS提供了一个实用程序类%Net.URLParser,可以使用它将URL字符串解析为其组成部分。例如,当您重定向HTTP请求时,这很有用。
该类包含一个类方法Parse(),它接受一个包含URL值的字符串,并通过引用返回一个包含URL各部分的数组。例如:
/// w ##class(PHA.TEST.HTTP).URLParser()
ClassMethod URLParser()
{
Set url = "https://www.google.com/search?q=Java+site%3Adocs.intersystems.com&oq=Java+site%3Adocs.intersystems.com"
Do ##class(%Net.URLParser).Parse(url,.components)
zw components
}
返回时,组件将包含此URL各部分的数组:
| Element | Value | Description |
|---|---|---|
components("fragment") |
null |
URL的片段(#字符后面) |
components("host") |
URL请求的主机 | |
| w | URL的网络地址 |
.png)
.png)


![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-f9VqwzNP-1608850948003)(3E1D939266954ED48BDAEA9B8086B11E)]](https://img-blog.csdnimg.cn/20201225070433434.png)
