gpt4 book ai didi

java - 如何在android中解析url

转载 作者:行者123 更新时间:2023-11-30 02:15:23 25 4
gpt4 key购买 nike

我有一个应该解析该值的 URL,但是当我给出时

private static String url = "http://54.174.74.84/api/index/index?data={%20%22language_code%22:%22en_us%22,%20%22cmd%22:%22search_projects%22,%20%22user_device_id%22:319,%20%22page%22:0,%20%22user_token%22:%22edeN2y0EuakoD2deWGzijeuBQ5HRnhokyAqV4WIHzZz5PM0Qn2xgopKiAcboNJktgXeQMsX7kZmDW3T5Tta3i+Fz1mU5p1yTP1L3m\/OTGkOlDoJrLn6\/+I3rBqESDtFH%22,%20%22source_app%22:%22android%22,%20%22longitude%22:%22567%22,%20%22user_id%22:67,%20%22latitude%22:%22123%22,%20%22records_per_page%22:%2210%22,%20%22search_key%22:%22%22%20}";

像这样显示错误。所以请帮助我。谢谢。

最佳答案

这不是错误。只需使用 java 编码器类进行字符串编码。你必须像下面的代码一样在使用它之前解码字符串......

String url = "http://54.174.74.84/api/index/index?data={%20%22language_code%22:%22en_us%22,%20%22cmd%22:%22search_projects%22,%20%22user_device_id%22:319,%20%22page%22:0,%20%22user_token%22:%22edeN2y0EuakoD2deWGzijeuBQ5HRnhokyAqV4WIHzZz5PM0Qn2xgopKiAcboNJktgXeQMsX7kZmDW3T5Tta3i+Fz1mU5p1yTP1L3m/OTGkOlDoJrLn6/+I3rBqESDtFH%22,%20%22source_app%22:%22android%22,%20%22longitude%22:%22567%22,%20%22user_id%22:67,%20%22latitude%22:%22123%22,%20%22records_per_page%22:%2210%22,%20%22search_key%22:%22%22%20}";

String result = java.net.URLDecoder.decode(url, "UTF-8");

关于java - 如何在android中解析url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29456329/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com