AFHTTPRequestOperationManager请求POST到服务器Java

时间:2014-02-11 16:35:20

标签: ios objective-c afnetworking-2

我是开发者iOS。我有一个关于AFHTTPRequestOperationManager请求POST到服务器(JBoss)Java的问题。当我用Multipart请求POST时响应很好,而不是问题。但是,当我只向服务器请求POST时,服务器显示错误:

  

11:57:19,815 ERROR [UserRest]登录电子邮件问题:null密码:   null 11:57:19,817 ERROR [STDERR] java.lang.Exception:MISSING ARGUMENTS

这个告诉我,发送参数为null。这个方法:

AFHTTPRequestOperation *)POST:(NSString *)URLString parameters:(NSDictionary *)parameters success:(void (^)(AFHTTPRequestOperation *operation, id responseObject))success failure:(void (^)(AFHTTPRequestOperation *operation, NSError *error))failure;

我不明白,为什么发送参数为null ..我的代码是:

NSString *strURL = @"http://YOUR_IP/YOUR_PATH/login";
__block const NSString *strResultResponse = @"";

AFHTTPRequestOperationManager *manager     = [AFHTTPRequestOperationManager manager];
manager.securityPolicy.allowInvalidCertificates = NO;

AFJSONRequestSerializer *serializerRequest = [AFJSONRequestSerializer serializer];
[serializerRequest setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];


AFJSONResponseSerializer *serializerResponse = [AFJSONResponseSerializer serializer];
serializerResponse.readingOptions = NSJSONReadingAllowFragments;
serializerResponse.acceptableContentTypes = [NSSet setWithObject:@"application/json"];

manager.requestSerializer = serializerRequest;
manager.responseSerializer = serializerResponse;

NSDictionary *parameters = @{@"email":@"xxxxxx@xxxx.xxxx",@"password":@"xxxx"};

[manager POST:strURL parameters:parameters
      success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSLog(@"%@", operation.responseString);    
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"%@", operation.responseString);
}];

我尝试了很多方法,但没有结果。请帮帮我。

0 个答案:

没有答案