问题描述:向服务端发送http请求,服务器端收到后返回结果,服务器端使用struts编写
NSString *myRequestString = @"mobile"; //参数
NSData *myRequestData = [ NSData dataWithBytes: [ myRequestString UTF8String ] length: [ myRequestString length ] ];
NSMutableURLRequest *request = [ [ NSMutableURLRequest alloc ] initWithURL: [ NSURL URLWithString: @"http://10.0.119.17:8080/st2/login.action"]];
[ request setHTTPMethod: @"POST" ];
[ request setHTTPBody: myRequestData ];
NSData *returnData = [ NSURLConnection sendSynchronousRequest: request returningResponse: nil error: nil ];
NSString* aStr = [[NSString alloc] initWithData:returnData encoding:NSASCIIStringEncoding];
NSLog(@"aStr = %@",aStr);