NSError *error=nil;
NSURL *url=[NSURL URLWithString:@"http://10.7.128.15:8089/gwk_alat/rest/MyPro/info"];
//这里利用NSUrlconnection进行post请求get不在做案例
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:url];
request.HTTPMethod=@"POST";
NSString *str=[NSString stringWithFormat:@"loginname=%@",@"dhj"];
request.HTTPBody=[str dataUsingEncoding:NSUTF8StringEncoding];
[NSURLConnection sendAsynchronousRequest:request queue:[NSOperationQueue alloc] init] completionHandler:^(NSURLresponse * response,NSData *data,NSError *connectionError){
if(connectionError==nil){
NSData *str=[NSURLConnection sendSynchronousRequet:request returningResponse:nil error:nil];
//解析str的json串
NSDictionary *root=[NSJSONSerialization JSONObjectWithData:str options:NSJSONReadingMutableLeaves error:nil];
NSString *value=[root objectForKey:@"name"];
NSLog(@"%@",value)
}
}