Android webview.postUrl(url,Encodingutils.getBytes(postData,“BASE64”))从postdata字符串中删除“+”
我从Webview发布到https服务器,如下面的URL所示,BASE64为charset。
将数据发送到WebView中加载的页面
我的postdata字符串是Base64编码的字符串,其中包含“+”。
当我按上述URL中所示的方式发布时,服务器日志显示缺少“+”的postdata字符串
我应该能够从Webview发布任何数据字符串,因为我将发布一个我无法控制的Base64编码字符串。
请帮我解决这个问题。
更新 :我甚至尝试过这样的
String postData = "fileContents=" + fileCon; mWebView.postUrl(url,postData.getBytes());
但发布时仍然会从postData中删除“+”。如果postData中没有“+”,则会正确发布。
+
是URL中的特殊字符,表示空格。 您需要在发送参数值之前对其进行URL编码。
String postData = "fileContents=" + URLEncoder.encode(fileCon, "UTF-8");