[英]Spring Android: how to post form urlencoded to server using percent-encoding
我如何配置RestTemplate(Springframework)以使用百分比編碼而不是字符編碼進行編碼,例如我將以下參數發布到服務器:
client_id = xxx
client_secret = xxx
grant_type = client_credentials
scope = public_read注冊
但是在發布時,spring將其發送為:
client_id = xxx&client_secret = xxx&grant_type = client_credentials&scope = public_read + registration
我希望它像這樣:
client_id = xxx&client_secret = xxx&grant_type = client_credentials&scope = public_read%20registration
它將空格轉換為+,我希望它是%20
謝謝
您可以使用此:
字符串formated_urlString = URLEncoder.encode(unformated_url_string,“ utf-8”)。replace(“ +”,“%20”)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.