iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题
2016-05-19 16:37
573 查看
使用AFNetworking出现报错:
error=ErrorDomain=com.alamofire.error.serialization.responseCode=-1016"Requestfailed:unacceptablecontent-type:text/html"UserInfo=0x7fdfd8729680{com.alamofire.serialization.response.error.response={URL:http://172.16.1.31:7001/itom/getwork}{statuscode:200,headers{
"Cache-Control"="no-cache";
"Content-Type"="text/html;charset=UTF-8";
Date="Mon,24Nov201403:13:16GMT";
"Transfer-Encoding"=Identity;
"X-Powered-By"="Servlet/2.5JSP/2.1";
å
解决方法:
self.acceptableContentTypes=[NSSetsetWithObjects:@"application/json",@"text/html",@"text/json",@"text/javascript",nil];
加上蓝色部分,其实就是添加一种服务器返回的数据格式。
亲测,好使。
error=ErrorDomain=com.alamofire.error.serialization.responseCode=-1016"Requestfailed:unacceptablecontent-type:text/html"UserInfo=0x7fdfd8729680{com.alamofire.serialization.response.error.response={URL:
"Cache-Control"="no-cache";
"Content-Type"="text/html;charset=UTF-8";
Date="Mon,24Nov201403:13:16GMT";
"Transfer-Encoding"=Identity;
"X-Powered-By"="Servlet/2.5JSP/2.1";
å
解决方法:
全工程搜索AFURLResponseSerialization.m文件
修改223行:
self.acceptableContentTypes=[NSSetsetWithObjects:@"application/json",@"text/html",@"text/json",@"text/javascript",nil];
加上蓝色部分,其实就是添加一种服务器返回的数据格式。
亲测,好使。
相关文章推荐
- ubuntu 下 super build Orfeo toobox和开发
- UICollectionView使用方法
- JDBC连接池、监控组件 Druid
- 如何把UIView转成UIImage,解决模糊失真问题
- Hue中给BI分配的权限
- iOS学习笔记之六--图片移动的基本界面 UIBotton的应用
- jeasyUI popWindow插件,适用jeasyui1.4.x
- UIScrollView 学习
- UICollectionView学习
- ToStringBuilder学习(一):常用方法介绍
- POJ 3061 Subsequence(尺取法)
- 用easyui动态创建一个对话框
- UITextField常用属性及键盘收回的几种方式
- C#和sqlserver中生成新的32位GUID
- UIKit控件直接显示网页文字内容
- UINavigationController 基本用法
- 24.UIViewController
- 4.SUID、SGID、SBIT、chattr权限
- UIImagePickerController本地图片视频,相机录像机使用
- ThreadPoolExecutor运转机制及BlockingQueue详解