我的应用程序我应该解析URl
,我应该从 ID
http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA
如何解析此网址并获取ID和教授?
答案 0 :(得分:1)
Uri uri=Uri.parse("http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA");
String id = uri.getQueryParameter("id");
String _prof = uri.getQueryParameter("_prof");
答案 1 :(得分:0)
Uri uri = Uri.parse("http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA");
String id = uri.getQueryParameter("id");
答案 2 :(得分:0)
试试这个
List<NameValuePair> parse = URLEncodedUtils.parse(URI.create("http://example.com/cat/detail/proc?id=147&_prof=W6IYDQZ2F2YOVBC78RUA"), "UTF-8");
for (NameValuePair pair : parse) {
System.out.println("!!!!!!!!!! " + pair.getName() + " = " + pair.getValue());
}