Android的webview.postUrl(URL,Encodingutils.getBytes(POSTDATA," BASE64"))去除" + QUOT;从PO

2023-09-06 18:11:32 作者:懞昧僦湜滈興

我从网页视图到HTTPS服务器发布如图所示以下网址与BASE64的字符集。

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

将数据发送到的WebView加载页面

我POSTDATA字符串是一个Base64恩在其codeD字符串以+

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

当我在上面的URL显示的方式公布我,服务器日志显示POSTDATA字符串缺少+

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

我应该能够从网页视图发布任何数据串,因为我将张贴关于这一点我没有控制的Base64恩codeD字符串。

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.

请帮我解决这个问题。

更新:我甚至尝试这样

String postData = "fileContents=" + fileCon;

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

但仍然是+是从POSTDATA删除当posting.If没有在POSTDATA+,它正确的帖子。

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

推荐答案

在URL和再$ P $的 + 是一个特殊字符psents的空间。在发送之前需要URL-CN code中的参数值。

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");