Android webview.postUrl(url,Encodingutils.getBytes

2019-05-26 02:52发布

I am posting from a Webview to the https server as shown in the below URL with BASE64 as charset.

Send data to page loaded in WebView

My postdata string is a Base64 encoded string with "+" in it.

When i am posting in the way as shown in the above URL, server log shows postdata string with a missing "+"

I should be able to post any data string from the Webview because i will be posting a Base64 Encoded string on which i don't have control.

Please help me solve this issue.

Update:I even tried like this

String postData = "fileContents=" + fileCon;

 mWebView.postUrl(url,postData.getBytes());

But still "+" is removed from postData when it is posting.If there is no "+" in the postData, it posts correctly.

1条回答
beautiful°
2楼-- · 2019-05-26 03:44

The + is a special character in URLs and represents a space. You need to URL-encode the parameter value before sending it.

String postData = "fileContents=" + URLEncoder.encode(fileCon, "UTF-8");
查看更多
登录 后发表回答