作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个应该解析该值的 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/
我是一名优秀的程序员,十分优秀!