如果我有这个网址
https://googledroids.com/post.html?limit=25&since=1374196005&md5=d8959d12ab687ed5db978cb078f1e&time=0dfdbac117
如何获取(或拆分)参数(避免硬编码)?
我需要分隔值:
- https协议
- googledroids.com
- /post.html
- 参数和值:
{limit=25, time=0dfdbac117, since=1374196005, md5=d8959d12ab687ed5db978cb078f1e}
2条答案
按热度按时间hvvq6cgz1#
下面的代码应该可以工作,它给出了一个参数值列表,而不是一个。
v1uwarro2#
使用类别:
我们可以使用值protocol、server、path、parameters,并且可以选择使用
uri.getQueryParameter()
获取特定的参数值:我们也可以获得参数列表(使用this question´s answer(java)):
这是使用
uri.queryParameterNames
获得参数和值的更好且简单的方法: