我正在尝试将一个字符串发布到iphone中的URL中,该URL将由服务器检索。服务器端脚本在Coldfusion中完成。我正试图在ColdFusion中获取数据,并将这些值传递给iphone。我对Coldfusion并不熟悉,希望得到一些帮助。下面是iphone编码:在coldfusion中从目标C获取POST值
/** iPhone码**/
NSString *post =[[NSString alloc] initWithString:@"Hello World"];
NSURL *url=[NSURL URLWithString:@"http://www.abc.com/test.cfm"];
NSData *postData = [post dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES];
NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSError *error;
NSURLResponse *response;
NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
/* ColdFusion代码*/
<html>
<head><title>Test</title></head>
<body>
<cfoutput>#form.post#</cfoutput>
</body>
</html>
我是不是做正确吗?
当您转储FORM范围时,您会看到什么? '' –
Leigh
[struct] empty - Leigh – lifemoveson
转储原始请求数据''和#URL# 。你看到了什么? http://help.adobe.com/zh_CN/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7c11.html –
Leigh