由网友(畅聊往事)分享简介:我在我的应用程序中的web视图和我加载 http://mysite.com/somepage.php I have a WebView in my app and I load http://mysite.com/somepage.php我知道我可以使用GET方法,因为这只会是正确的URL字符串传递数据。我想知道我...
我在我的应用程序中的web视图和我加载 http://mysite.com/somepage.php
I have a WebView in my app and I load http://mysite.com/somepage.php
我知道我可以使用GET方法,因为这只会是正确的URL字符串传递数据。我想知道我怎么可以传递数据,使用POST方法的页面。我试图寻找,但我无法找到任何具体。谢谢你。
I know I can pass data using the GET method because that would just be right in the URL string. I was wondering how I could pass data to the page using the POST method. I tried searching but I cannot find anything specific. Thanks.
推荐答案
有一个在的WebView名为
postUrl
的方法
There's a method called postUrl
in WebView
.
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
或者
If base64
didn't work, try BASE64
alternatively.
希望它会正常工作。
相关推荐
最新文章