NSURLRequest POST方式请求
2015-10-20 15:10
260 查看
NSURLRequest POST方式请求
1
NSString *urlString = [NSString stringWithFormat:@"http://jssb.zust.edu.cn/androidLogin.action"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
2头
NSString *contentType = [NSString stringWithFormat:@"text/xml"];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
3、数据内容体的设定
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"id=%@&password=%@&role=%@",@"admin02",@"admin02",@"dean"] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postBody];
1
NSString *urlString = [NSString stringWithFormat:@"http://jssb.zust.edu.cn/androidLogin.action"];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"POST"];
2头
NSString *contentType = [NSString stringWithFormat:@"text/xml"];
[request addValue:contentType forHTTPHeaderField: @"Content-Type"];
3、数据内容体的设定
NSMutableData *postBody = [NSMutableData data];
[postBody appendData:[[NSString stringWithFormat:@"id=%@&password=%@&role=%@",@"admin02",@"admin02",@"dean"] dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postBody];
相关文章推荐
- 获取<meta-data>元素的value属性的值
- StringBuilder和StringBuffer区别
- easyui datagrid 诡异的无法显示问题
- 二、通过纯代码创建的UICollectionView的简单使用
- EasyUi Grid以POST方式传送参数绑定
- conn.setAutoCommit(true)和(false)的区别
- Ubuntu中crosstool-ng编译出错:[ERROR] gtype-desc.c:8829:18: error: subscripted value is neither array nor
- Android ui utils-简单实用的Android界面工具
- UE3代码阅读需知
- Druid使用说明
- Easyui 中 Tabsr的常用方法
- easyUI排序问题
- UINavgationViewController
- UITableview中的backgroundView
- 探秘Java中的String、StringBuilder以及StringBuffer
- Android build system & Android.mk 规范
- UIImageView显示问题
- iOS之UI高级---触摸事件
- iOS工作中的问题-----navigationBar透明方法、遮挡UIViewController、UITableViewController 视图解决方法
- Leetcode Unique Paths II