我想在android中使用webview发布数据。试过下面的代码,
String postdata="username=abcd";
myWebView.postUrl(url, EncodingUtils.getBytes(postData, "BASE64"));
但未获得所需的输出。如果有任何其他方式在网页浏览中发布数据,请与我们联系。
在内部监督办公室也是如此,并成功实施。如下所示是IOS中的代码:
NSString *loginUrl = @"https://www.abcdefgh.com/SellOnline/j_spring_check";
NSURL *url = [NSURL URLWithString:loginUrl];
NSMutableURLRequest *requestObj = [NSMutableURLRequest requestWithURL:url];
// POST the username password
[requestObj setHTTPMethod:@"POST"];
NSString *postString = [NSString stringWithFormat:@"agent=%@", @"839878"];
NSData *data = [postString dataUsingEncoding: NSUTF8StringEncoding];
[requestObj setHTTPBody:data];
self.webview.delegate = self;
[self.webview loadRequest:requestObj];\
答案 0 :(得分:0)
Load the WebView In FIle
WebView webvHelp = (WebView) findViewById(R.id.webvHelp);
progressBar = (ProgressBar) findViewById(R.id.progressBar);
progressBar.getProgressDrawable().setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_IN);
webvHelp.getSettings().setBuiltInZoomControls(true);
webvHelp.getSettings().setDisplayZoomControls(false);
webvHelp.setWebChromeClient(new WebChromeClient()
{
public void onProgressChanged(WebView view, int progress)
{
progressBar.setProgress(progress * 100);
}
});
webvHelp.setWebViewClient(new WebViewClient()
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
if (!progressBar.isShown())
{
progressBar.setVisibility(View.VISIBLE);
}
super.onPageStarted(view, url, favicon);
}
@Override
public void onPageFinished(WebView view, String url) {
if (progressBar.isShown()) {
progressBar.setVisibility(View.GONE);
}
super.onPageFinished(view, url);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
{
view.loadUrl(url);
return super.shouldOverrideUrlLoading(view, url);
}
});
webvHelp.loadUrl(HELP_URL);