【发布时间】:2011-06-02 17:44:39
【问题描述】:
我的应用中有一个 WebView,我加载了 http://mysite.com/somepage.php
我知道我可以使用 GET 方法传递数据,因为这正好在 URL 字符串中。我想知道如何使用 POST 方法将数据传递到页面。我尝试搜索,但找不到任何具体内容。谢谢。
【问题讨论】:
标签: android post webview http-post
我的应用中有一个 WebView,我加载了 http://mysite.com/somepage.php
我知道我可以使用 GET 方法传递数据,因为这正好在 URL 字符串中。我想知道如何使用 POST 方法将数据传递到页面。我尝试搜索,但找不到任何具体内容。谢谢。
【问题讨论】:
标签: android post webview http-post
WebView 中有一个名为postUrl 的方法。
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView webView = new WebView(this);
setContentView(webView);
String url = "http://mysite.com/somepage.php";
String postData = "postvar=value";
webView.postUrl(url, EncodingUtils.getBytes(postData, "base64"));
}
如果base64 不起作用,请尝试BASE64。
希望它能正常工作。
【讨论】: