NSURL *url = [NSURL URLWithString:@"http://ip/login"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
NSString *body = [NSString stringWithFormat: @"name=%@&pass=%@", @"phpxiaoxin", @"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8"];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];
[request setHTTPMethod: @"POST"];
//Load the request in the UIWebView.
[webView loadRequest:request];
url = [NSURL URLWithString:@"http://ip/hotel/hotelReservationList.action"];
request = [[NSMutableURLRequest alloc]initWithURL: url];
[webView loadRequest:request];
大家好,我对 uiwebview session 原因有疑问; 现在首先我想使用 postmethod 登录系统 然后我需要控制重定向到“hotelreservation.action”的操作 但第二个请求并没有延长第一个 session ,因此结果是Web系统重定向到登录页面 我应该用 uiwebview 做什么,我知道我可以在 web 中重定向,但我确实需要通过 webview 进行控制。 所以有人可以帮助我吗?非常感谢
最佳答案
您应该在 UIWebViewDelegate
的 webViewDidFinishLoad:
方法中执行第二个请求。
关于iphone - uiwebview session 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2347671/