AFNetWorking3.1的POST到JAVA后台接收不到params的数据的解决方案
- 在初始化AFNHttpRequestPOCManager的时候进行以下配置进行网络请求是发生上述错误的配置
_shareAFNHttpRequestOPManager = [[self alloc] initWithBaseURL:[NSURL URLWithString:Base_Url]];
NSSet *typeSet=[NSSet setWithObjects:@"application/json",
@"text/json",
@"text/javascript",
@"text/html",
@"text/css",
@"text/plain",
@"charset/UTF-8",nil];
// _shareAFNHttpRequestOPManager.requestSerializer=[AFJSONRequestSerializer serializer];
_shareAFNHttpRequestOPManager.requestSerializer.timeoutInterval=120;
[_shareAFNHttpRequestOPManager.requestSerializer setStringEncoding:NSUTF8StringEncoding];
// _shareAFNHttpRequestOPManager.responseSerializer=[AFHTTPResponseSerializer serializer];
// _shareAFNHttpRequestOPManager.responseSerializer.acceptableContentTypes =typeSet;
_shareAFNHttpRequestOPManager = [[self alloc] initWithBaseURL:[NSURL URLWithString:Base_Url]];
_shareAFNHttpRequestOPManager.requestSerializer.timeoutInterval=120;
[_shareAFNHttpRequestOPManager.requestSerializer setStringEncoding:NSUTF8StringEncoding];
- 原因猜测:有可能是在配置responseSerializer的acceptableContentTypes和服务器的配置没有保持一致,从而导致服务器无法接收参数
参考资料: