怎么获取 QWebView post的数据

怎么获取 QWebView post的数据,第1张

void QWebView::load ( const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray() ) 试试

由于种种因素,现在国内的移动开发大都是原生和html5混合开发, 那么iOS端的UIWebView和WKWebView就启到了非常重要的作用! 而从我们原生页面跳转的web页面的时候我们往往需要像前端传递参数,今天我们要说的就是:webView怎么加载post请求并传递参数!

代码如下:

UIWebView *webView = [[UIWebView alloc] init]

NSString *bodyShare = [NSString stringWithFormat: @"hID=%@", userID]

NSMutableURLRequest * requestShare = [[NSMutableURLRequest alloc]initWithURL:[NSURL URLWithString:self.urlStr]]

[requestShare setHTTPMethod: @"POST"]

[requestShare setHTTPBody: [bodyShare dataUsingEncoding: NSUTF8StringEncoding]]

[webView loadRequest:requestShare]

当然与之相对应的还有get请求来传递参数的,代码如下:

UIWebView *webView = [[UIWebView alloc] init]

self.urlStr = [NSString stringWithFormat:@"%@/tokenredirect?ostype=iphone&token=%@&time=%@",kServerPrefixURL,token,time]

NSURLRequest * requestShare = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:self.urlStr]]

[webView loadRequest:requestShare]


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/6779642.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-03-28
下一篇2023-03-28

发表评论

登录后才能评论

评论列表(0条)

    保存