webview链接 get和post请求传值给链接的页面

来源:互联网 发布:java中的泛型机制 编辑:程序博客网 时间:2024/06/08 02:10
get请求

    url = [[ NSURL alloc] initWithString:@"http://www.********.com.cn:8081/index.php/Account/iphoneTopup?email=a@a.com&password=1&amount=12"];
    [WebView  loadRequest:[ NSURLRequest requestWithURL: url ]]; //习惯采用loadRequest方式,你可采用其他方式
   
  post请求

    NSURL *url = [NSURL URLWithString: @"http://www.*******.com.cn:8081/index.php/Account/iphoneTopup"];
    NSString *body = [NSString stringWithFormat: @"email=%@&password=%@&amount=%@",@"a@a.com",@"1",@"12"];
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
    [request setHTTPMethod: @"POST"];
    [request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];
    [WebView loadRequest: request];
0 0
原创粉丝点击