AFHTTPRequestOperationManager * manager = [AFHTTPRequestOperationManager manager]; // manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.responseSerializer = [AFHTTPResponseSerializer serializer]; manager.responseSerializer.acceptableContentTypes = [manager.responseSerializer.acceptableContentTypes setByAddingObject: @"text/plain"]; [manager POST:@"http://wu.itmingong.org:9090/WuNetbars/app/login.do"parameters:parameters success:^(AFHTTPRequestOperation *operation,idresponseObject) { // NSDictionary * dic = [NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingMutableContainers error:nil]; NSLog(@"success"); } failure:^(AFHTTPRequestOperation *operation,NSError*error) { NSLog(@"错误,%@", error); }]; |
是请求头的问题么?求大神指点
终于搞好了,原因是我用加密过的字符串,其中有加减等特殊符号,AFN框架直接处理字符串时会改变这些特殊符号和加些字符串,所以修改AFN内部这一部分即可
NSString *query = nil; if (self.queryStringSerialization) { NSError *serializationError; query = self.queryStringSerialization(request, parameters, &serializationError); if (serializationError) { if (error) { *error = serializationError; } return nil; } query = (NSString *)parameters;添加最后一句就好了,前面是AFN判断修改的