如何让URLEncoding不对冒号进行编码? [英] How can i make URLEncoding not encode colon?
本文介绍了如何让URLEncoding不对冒号进行编码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个JSONObject:
I have a JSONObject:
{user:{"firstname":"testuser","surname":"æøå"}}
所以我在对象中有这些特殊字符
So i have these special characters in the object
I URLEncode我有的jsonString。
I URLEncode the jsonString i have.
urlEncodedJsonReq = URLEncoder.encode("{user:{\"firstname\":\"testuser\",\"surname\":\"æøå\"}}","UTF-8");
我收到服务器的回复:你提交的URI不允许使用字符。
这是编码的网址: serverurl /%7Buser%3A%7B%22firstname%22%3A%22testuser%22%2C%22sameame%22%3A%22%C3%A6%C3 %B8%C3%A5%22%7D%7D
I get a response from the server: "The URI you submitted has disallowed characters.".
This is the encoded url: serverurl/%7Buser%3A%7B%22firstname%22%3A%22testuser%22%2C%22surname%22%3A%22%C3%A6%C3%B8%C3%A5%22%7D%7D
但我需要的是:
%7Buser:%7B%22firstname%22:%22testuser%22%2C%22surname%22:%22%C3%A6%C3%B8%C3%A5%22%7D%7D
这是否可以以合理的方式实现?
Is this possible in any reasonable way?
提前致谢
推荐答案
是,或者干脆:
URLEncoder.encode(theUrl).replace("%3A", ":");
这篇关于如何让URLEncoding不对冒号进行编码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文