1. [代码][C/C++]代码     
    NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init]; 
    NSUserDefaults *defs = [NSUserDefaults standardUserDefaults];    
    NSLog(@"Load currentCookie:%@", cookie);
    [request setValue:cookie forHTTPHeaderField:@"Cookie"];
    [request setURL:[a objectAtIndex:0]];
    [request setHTTPMethod:@"GET"];
    NSData *returnData = [NSURLConnection sendSynchronousRequest:request 
                                               returningResponse:nil error:nil]; 
    [request release];
2. [代码]一、iPhone终端代码:     
NSString *post = nil;  
post = [[NSString alloc] initWithFormat:@"message=%@",@"hello,world."];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];  
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];  
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];  
[request setURL:[NSURL URLWithString:@"http://192.168.10.220:18080/data/1.jsp"]];  
[request setHTTPMethod:@"POST"]; 
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];  
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];  
[request setHTTPBody:postData];  网站模板
//[NSURLConnection connectionWithRequest:request delegate:self ];

//同步请求的的代码
//returnData就是返回得到的数据
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningRequest:nil error:nil];
[post release]; 
3. [代码]二、web服务器端代码     
<%
String message = request.getParameter("message");
System.out.println("message="+message);
out.println("message="+message);
%>
4. [代码]采用json 格式post 字符串     
static NSString *urlString = @"http://192.168.1.103/WebAccess/admin/tablesSync.aspx";
 //static NSString *urlString = @"http://www.google.cn";
 NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:[NSURL URLWithString:urlString]];
 NSString *httpBodyString = @"a test string";
 
 NSMutableArray *arrayData = [[NSMutableArray alloc] init];
 
 NSMutableDictionary *dlist = [[NSMutableDictionary alloc] init];
 [dlist setObject:@"tblArea" forKey:@"tableName"]; 
 [dlist setObject:@"2009-10-24 11:20:00" forKey:@"lastChangeDate"];
 [arrayData addObject:dlist];
  
 //[request setHTTPBody:[httpBodyString dataUsingEncoding:NSUTF8StringEncoding]];
 //
   //post = [[NSString alloc] initWithFormat:@"message=%@",@"hello,world."];
 httpBodyString = [arrayData JSONRepresentation];
 NSData *postData = [httpBodyString dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];  
 [request setHTTPBody:postData]; http://www.huiyi8.com/moban/​
 [request setHTTPMethod:@"POST"];
 //
 NSURLResponse *reponse;
 NSError *error = nil;
 //
 NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&reponse error:&error];
 if (error) {
  NSLog(@"Something wrong: %@",[error description]);
 }else {
  if (responseData) {
   NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
   NSLog(@"get %@",responseString);
  }
 }

NSMutableDictionary *dgetData = [responseString JSONValue];
NSLog(@"dgetData: %@" , [dgetData description]);

[dlist release];
[arrayData release];

NSMutableURLRequest,在POST方式下传递参数的更多相关文章

  1. Jmeter在非GUI环境下传递参数(命令行&Jenkins配置)

    https://www.cnblogs.com/kill0001000/p/8078686.html 通过cmd运行 jmeter -? 可以得到所有命令行选项(本文最后) 其中可以看到下面 -J 的 ...

  2. Android解惑 - 为什么要用Fragment.setArguments(Bundle bundle)来传递参数(转)

    Fragment在Android3.0开始提供,并且在兼容包中也提供了Fragment特性的支持.Fragment的推出让我们编写和管理用户界面更快捷更方便了.   但当我们实例化自定义Fragmen ...

  3. C#传递参数调用exe程序

    今天公司让我把Winform程序里的一块单独成一个exe文件,从原程序中打开新的exe程序,这就涉及到参数的传递,故来记录下传递参数到exe程序的方式 第一种方式 首先在程序A中添加引用using S ...

  4. hadoop传递参数方法总结

    转自:http://blog.csdn.net/xichenguan/article/details/22162813 写MapReduce程序通常要传递各种各样的参数,选择合适的方式来传递参数既能提 ...

  5. C#传递参数

    与函数交换数据的最好方式就是传递参数,在C#中有四种方法来控制参数如何传递给目标方法 C#中的参数修饰符 无修饰 如果一个参数没有用参数修饰符,则认为它将按值传递 out 输出参数由被调用的方法赋值. ...

  6. linux命令行传递参数定期执行PHP文件

    最近在做一个项目,需要在linux下传递参数定期执行PHP文件,网上查询资料,确实有相关资料,现整理如下: 1.linux执行PHP文件 #{PHP安装bin路径} {PHP文件路径} {需要参数1 ...

  7. URL中传递参数给视图函数

    1. 采用在url中使用变量的方式: 在path的第一个参数中,使用<参数名>的方式可以传递参数.然后在视图函数中也要写一个参数,视图函数中的参数必须和url中的参数名称保持一致,不然就找 ...

  8. centos shell编程4【分发系统】 服务器标准化 mkpasswd 生成密码的工具 expect讲解 expect传递参数 expect自动同步文件 expect指定host和要同步的文件 expect文件分发系统 expect自动发送密钥脚本 Linux脚本执行方式 第三十八节课

    centos shell编程4[分发系统] 服务器标准化  mkpasswd 生成密码的工具  expect讲解   expect传递参数   expect自动同步文件  expect指定host和要 ...

  9. asp传递参数的几种方式

    把下列代码分别加入a.asp和b.asp的<body></body>中,点提交,就可以将a.asp文本框的内容传给b.asp并显示出来 a.ASP <form actio ...

随机推荐

  1. python 依照list中的dic的某key排序

    面试题之中的一个. s=[ {"name":"Axx","score":"90"}, {"name" ...

  2. cocos2d-x入口类

    上一篇文章中有一个在栈中创建的实例--AppDelegate.这个类的初始化使cocos2d-x的程序能够执行起来.由于它是继承于CCApplication类.而执行的run方法就是在此类中实现的. ...

  3. C语言-多重背包问题

    多重背包问题 问题:有N种物品和一个容量为V的背包.第i种物品最多有n[i]件可用,每件费用是c[i],价值是w[i].求解将哪些物品装入背包可使这些物品的费用总和不超过背包容量,且价值总和最大. 分 ...

  4. Twitter网站架构分析介绍

    http://www.kaiyuanba.cn/html/1/131/147/7539.htm作为140个字的缔造者,twitter太简单了,又太复杂了,简单是因为仅仅用140个字居然使有几次世界性事 ...

  5. JavaScript的string方法(demo)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  6. linux下nginx+php+mysql 自助环境搭建

    ++++++++++++++++++++++++++++++++++++++++++++++linux下nginx+php+mysql环境搭建+++++++++++++++++++++++++++++ ...

  7. JS 常用字符串操作

    Js字符串操作函数大全 /*******************************************                        字符串函数扩充              ...

  8. webstorm 设置IP 访问 手机测试效果

    http://www.cnblogs.com/gulei/p/5126383.html 前端开发中,经常需要将做好的页面给其他同事预览或手机测试,之前一直用的第三方本地服务器usbwebserver, ...

  9. JS控制input 文本框只允许输入汉字

    onblur="value=value.replace(/[^/u4E00-/u9FA5]/g,'')" onbeforepaste="clipboardData.set ...

  10. GreenPlum 安装方法详解

    一.安装环境准备 1.磁盘环境准备 磁盘分区典型配置如下: 文件系统 文件格式    大小  /        ext3   50GB,Linux系统的根目录,所有的目录都挂在这个目录下面,建议大小为 ...