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. [ONTAK2010]Peaks

    题目大意: 一个图上有$n(n\leq100000)$个带权点,$m(m\leq500000)$条带权边.有$q(q\leq500000)$组询问,每次询问从点$v$出发,只经过权值小于等于$x$的边 ...

  2. 【Maven jar】打包单个或多个文件,有依赖jar包的将架包一起打包成一个jar包供别的项目引用

    之前有一片文章,是打包单个java文件的.这次想要将http://www.cnblogs.com/sxdcgaq8080/p/8398780.html  打包成jar包,发现这个java文件中引用了多 ...

  3. 阿里云云服务器ubuntu配置nginx+uwsgi+django记录文档

    1 安装ssh 1  sudo apt-get update 2  sudo apt-get install openssh-server 3  sudo ps -e |grep ssh  有sshd ...

  4. 手机遥控器,3.5mm耳机接口红外遥控改造解析

    很多家电都用红外遥控,如电视机.机顶盒.空调.电风扇等.越来越多的遥控器反而给我们带来了更多的问题,有时找不到遥控器放哪儿了,或者混淆了都是麻烦,事实上对手机进行简单的改造,可以自制一个万能红外遥控器 ...

  5. DAO 层实现

    一.实验介绍 1.1 实验内容 本节课程主要利用 MyBatis 框架实现 DAO 层. 1.2 实验知识点 MyBatis 框架 MySQL 1.3 实验环境 JDK1.8 Eclipse Java ...

  6. Java自定义注解和运行时靠反射获取注解

    转载:http://blog.csdn.net/bao19901210/article/details/17201173/ java自定义注解 Java注解是附加在代码中的一些元信息,用于一些工具在编 ...

  7. IntelliJ IDEA 10.5.1 引用外部Jar包

    具体步骤: File -> Project Structure (ctrl + shift + alt + s ) -> Module -> Dependencies -> A ...

  8. ios You app information could not be saved. Try again. If the problem persists, contact us

    ios You app information could not be saved. Try again. If the problem persists, contact us  大概意思:你的a ...

  9. c语言-完全背包问题

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

  10. CrtmpServer getApplication注册流程

    最近在研究 CrtmpServer getApplication注册流程,以备查阅 图1. 加载动态库流程 图2配置application流程