iOS AFNetworking “Request failed: unacceptable content-type: text/html”问题
2015-06-01 23:42
381 查看
使用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];
加上蓝色部分,其实就是添加一种服务器返回的数据格式。
亲测,好使。
相关文章推荐
- 为什么很多内置类如UITableViewController的delegate属性都是assign而不是retain的?
- Android Studio导入uiautomator测试框架
- iOS开发 --制作圆形的头像(UIImage)
- hdu 1711 Number Sequence KMP模板题
- Maximum Subsequence Sum
- iOS UIview 学习
- SSDB --- queue实现
- IOS初级:UIwindow
- android蓝牙框架bluedroid之sbc编码
- 【Android UI设计与开发】第02期:引导界面(二)使用ViewPager实现欢迎引导页面
- UIView UIWindow
- (转)IOS UITableView学习
- 关于easyui Tree取得选中节点的父级节点(得到选取实心圆点的id)
- UIView 中常见的方法总结
- Java中带标签的break、continue
- UISearchDisplayController搜索(iOS8前)
- 关于UITweener老是卡帧的问题
- How to replace a value in web.xml with a Maven property?(转)
- Android---手动创建线程与GUI线程同步(三)
- 020_01UI组件之Dialog详细用法